Skip to content

Latest commit

 

History

History
122 lines (108 loc) · 3.99 KB

LOCALAPP.md

File metadata and controls

122 lines (108 loc) · 3.99 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 5.0 SDK
  2. Newest Git
  3. A code editor - we like Visual Studio Code
  4. For Windows/MacOS 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

  1. Clone the altinn-studio repository to a local folder
    git clone https://github.com/Altinn/altinn-studio
    cd altinn-studio
  2. Navigate to the development folder in the altinn-studio repo
    cd src/development
  3. Setting up loadbalancer
    • Windows:
      Start the loadbalancer container that routes between the local platform services and the app
      docker-compose up -d --build
    • 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
  4. 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 AppRepositoryBasePath to the parent folder where you have your application repos (C:/repos/ as an example) as to your app on the disk.
    • Change the setting LocalTestingStaticTestDataPath to the full path of the altinn-studio repository. For example:
      "C:/repos/altinn-studio/src/development/TestData/"
    • Save the file.
  5. Start the local platform services (make sure you are in the LocalTest folder)
    dotnet run
  6. Navigate to the app folder (specified in the step above)
    cd \.\<path to app on disk>
  7. 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 http://altinn3local.no.

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