Skip to content

Latest commit

 

History

History
160 lines (103 loc) · 3.6 KB

LOCALAPP.md

File metadata and controls

160 lines (103 loc) · 3.6 KB

Local testing of apps

It is possible to test and debug applications created in Altinn Studio on local development machine.

Currently we have not been able to provide a 100% common setup between Windows and Linux.

Prerequisites

  1. Latest .NET Core 3.1 SDK
  2. Newest Git
  3. A code editor - we like Visual Studio Code
  4. For Windows/MAC Docker Desktop
  5. Update hosts file (C:/Windows/System32/drivers/etc/hosts) by adding the following values. On MacOS add the same values to values /private/etc/hosts using cmd sudo nano /private/etc/hosts.
127.0.0.1 altinn3local.no

Setup

Clone the Altinn Studio repository

git clone https://github.com/Altinn/altinn-studio
cd altinn-studio

Navigate to the development folder in the altinn-studio repo

  1. Navigate to the development folder in the altinn-studio repo
cd src/development

2a. Setting up loadbalancer Windows

Start the loadbalancer container that routes between the local platform services and the app

docker-compose up -d --build

2b. Setting up loadbalancer Linux

Install NGINX

sudo apt-get update
sudo apt-get install nginx
sudo service nginx start

Edit the NGINX configuration

cd /etc/nginx
sudo nano nginx.conf

Modify the default to this.

worker_processes 1;

events { worker_connections 1024; }

http {

    client_max_body_size 50M;

    sendfile on;

	upstream localtest {
        server 127.0.0.1:5101;
    }

    upstream app {
        server 127.0.0.1:5005;
    }

    server {
		listen 80;
        server_name altinn3local.no localhost;

        proxy_redirect      off;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;


		location = / {
        proxy_pass          http://localtest/Home/;
		}

		location / {
        proxy_pass          http://app/;
		}

		location /Home/ {
			  proxy_pass		      http://localtest/Home/;
		}

    		location /localtestresources/ {
			  proxy_pass		      http://localtest/localtestresources/;
		}

	}
}

Save and go back to src/develpment folder in altinn-studio

Reload NGINX configuration

sudo nginx -s reload
  1. Set path to app folder in local platform services:
  • Open appSettings.json in the LocalTest folder, f.ex. in Visual Studio Code
cd LocalTest
code appSettings.json
  • Change the setting "AppRepsitoryBasePath" to the parent folder where you have your application repos (c:/repos/ as an example) as to your app on the disk. Save the file.
  • Change the setting "LocalTestingStaticTestDataPath"to the full path of this repo.
  1. Start the local platform services (make sure you are in the LocalTest folder)
dotnet run
  1. Navigate to the app folder (specified in the step above)
cd \.\<path to app on disk>
  1. Start the app locally
dotnet run -p App.csproj

The app and local platform services are now running locally. The app can be accessed on altinn3local.no.

Log in with a test user, using your app name and org name. This will redirect you to the app.