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.
- Latest .NET Core 3.1 SDK
- Newest Git
- A code editor - we like Visual Studio Code
- Also install recommended extensions (f.ex. C# and Debugger for Chrome)
- For Windows/MAC Docker Desktop
- 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
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
- 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
- Set path to app folder in local platform services:
- Open
appSettings.json
in theLocalTest
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.
- Start the local platform services (make sure you are in the LocalTest folder)
dotnet run
- Navigate to the app folder (specified in the step above)
cd \.\<path to app on disk>
- 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.