Skip to content

Commit

Permalink
Feature/podman support (#72)
Browse files Browse the repository at this point in the history
* Add separate configs for podman and update the readme to reflect changes made earlier (removal of profiles)

* make separate setup section for podman
  • Loading branch information
tjololo authored Dec 13, 2023
1 parent 3cfd11c commit c55ae94
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## What port should the loadbalancer use?
## sometimes PCs have another service running on port 80, so you might need to
## change this.
## change this. Default in podman-compose.yml is 8080 as ports below 1024 are privileged ports on most unix systems.

#ALTINN3LOCAL_PORT=80

Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.PHONY: start-localtest
start-localtest:
docker-compose --profile localtest up -d --build
.PHONY: docker-start-localtest
docker-start-localtest:
docker-compose up -d --build

.PHONY: stop-localtest
stop-localtest:
docker-compose --profile localtest down
.PHONY: docker-stop-localtest
docker-stop-localtest:
docker-compose down

.PHONY: start-localtest-new-pdf
start-localtest-new-pdf:
docker-compose --profile localtest --profile pdf up -d --build

.PHONY: stop-localtest-new-pdf
stop-localtest-new-pdf:
docker-compose --profile localtest --profile pdf down
.PHONY: podman-start-localtest
podman-start-localtest:
podman compose --file podman-compose.yml up -d --build
.PHONY: podman-stop-localtest
podman-stop-localtest:
podman compose --file podman-compose.yml down
58 changes: 50 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ These are some of the required steps, tips, and tricks when it comes to running

### Setup

#### Using docker

1. Clone the `app-localtest` repository to a local folder and move into the folder.

```shell
Expand All @@ -28,15 +30,16 @@ These are some of the required steps, tips, and tricks when it comes to running
2. Build and run the containers in the background.

```shell
docker compose --profile localtest up -d --build
docker compose up -d --build
```

This mode supports running one app at a time. If you need to run multiple apps at once, remove `--profile localtest` from the command and follow the instructions below to run LocalTest locally outside Docker.
:information_source: If you are using linux or mac you can use the Makefile to build and run the containers.

Note: Using profiles requires docker-compose version [1.28.0](https://docs.docker.com/compose/release-notes/#1280)
or later. If your version does not support profiles and you prefer to run localtest in Docker, make sure to follow
[the instructions to install more a recent version](https://docs.docker.com/engine/install/) or comment out
the profile restriction in `docker-compose.yml`.
```shell
make docker-start-localtest
```

This mode supports running one app at a time. If you need to run multiple apps at once, stop the localtest container with `docker stop localtest` and follow the instructions below to run LocalTest locally outside Docker.

3. Start your app
_This step requires that you have already [created an app](https://docs.altinn.studio/app/getting-started/create-app/), added a [data model](https://docs.altinn.studio/app/development/data/data-model/data-models-tool/), and [cloned the app](https://docs.altinn.studio/app/getting-started/local-dev/) to your local environment._
Expand All @@ -55,6 +58,46 @@ These are some of the required steps, tips, and tricks when it comes to running
dotnet run
```

#### Using podman

1. Clone the `app-localtest` repository to a local folder and move into the folder.

```shell
git clone https://github.com/Altinn/app-localtest
cd app-localtest
```

2. Build and run the containers in the background.

```shell
podman compose --file podman-compose.yml up -d --build
```

:information_source: If you are using linux or mac you can use the Makefile to build and run the containers.

```shell
make podman-start-localtest
```

This mode supports running one app at a time. If you need to run multiple apps at once, stop the localtest container with `podman stop localtest` and follow the instructions below to run LocalTest locally outside Docker.

3. Start your app
_This step requires that you have already [created an app](https://docs.altinn.studio/app/getting-started/create-app/), added a [data model](https://docs.altinn.studio/app/development/data/data-model/data-models-tool/), and [cloned the app](https://docs.altinn.studio/app/getting-started/local-dev/) to your local environment._

Move into the `App` folder of your application.

Example: If your application is named `my-awesome-app` and is located in the folder `C:\my_applications`, run the following command:

```shell
cd C:\my_applications\my-awasome-app\App
```

Run the application:

```shell
dotnet run
```

The app and local platform services are now running locally. The app can be accessed on <http://local.altinn.cloud>.

Log in with a test user, using your app name and org name. This will redirect you to the app.
Expand Down Expand Up @@ -90,8 +133,7 @@ The setup described above (LocalTest running in Docker) currently only supports
yourself needing to run multiple apps at the same time, or if you need to debug or develop LocalTest, a local setup is
preferred.

:information_source: If you're already running LocalTest in Docker, be sure to stop the container or make sure you
omit `--profile localtest` when running `docker compose`.
:information_source: If you're already running LocalTest in Docker, be sure to stop the container with `docker stop localtest`
**Configuration of LocalTest**
The LocalTest application acts as an emulator of the Altinn 3 platform services. It provides things like authentication,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- NGINX_HOST=localhost
- NGINX_PORT=80
- TEST_DOMAIN=${TEST_DOMAIN:-local.altinn.cloud}
- INTERNAL_DOMAIN=host.docker.internal
- ALTINN3LOCAL_PORT=${ALTINN3LOCAL_PORT:-80}
- NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/
- NGINX_ENVSUBST_TEMPLATE_SUFFIX=.conf
Expand Down
10 changes: 5 additions & 5 deletions loadbalancer/templates/nginx.conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ http {
sendfile on;

upstream localtest {
server host.docker.internal:5101;
server ${INTERNAL_DOMAIN}:5101;
}

upstream app {
server host.docker.internal:5005;
server ${INTERNAL_DOMAIN}:5005;
}
# Redirect localhost and the old altinn3local.no to the configured test domain
server {
Expand All @@ -46,15 +46,15 @@ http {
}

upstream receiptcomp {
server host.docker.internal:5060;
server ${INTERNAL_DOMAIN}:5060;
}

upstream pdfservice {
server host.docker.internal:5300;
server ${INTERNAL_DOMAIN}:5300;
}

upstream accessmanagementcomp {
server host.docker.internal:5117;
server ${INTERNAL_DOMAIN}:5117;
}

server {
Expand Down
67 changes: 67 additions & 0 deletions podman-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3.6'

networks:
altinntestlocal_network:
external: false

services:
local.altinn.cloud:
container_name: localtest-loadbalancer
image: nginx:alpine-perl
restart: always
networks:
- altinntestlocal_network
ports:
- "${ALTINN3LOCAL_PORT:-8080}:80"
environment:
- NGINX_HOST=localhost
- NGINX_PORT=80
- TEST_DOMAIN=${TEST_DOMAIN:-local.altinn.cloud}
- INTERNAL_DOMAIN=host.containers.internal
- ALTINN3LOCAL_PORT=${ALTINN3LOCAL_PORT:-80}
- NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/
- NGINX_ENVSUBST_TEMPLATE_SUFFIX=.conf
volumes:
- ./loadbalancer/templates:/etc/nginx/templates/:ro
- ./loadbalancer/www:/www/:ro


altinn_platform_pdf:
container_name: altinn-pdf
platform: linux/amd64
image: ghcr.io/altinn/altinn-pdf:latest
restart: always
networks:
- altinntestlocal_network
ports:
- "5070:5070"
altinn_pdf_service:
container_name: altinn-pdf-service
image: browserless/chrome:1-puppeteer-19.2.2
restart: always
networks:
- altinntestlocal_network
ports:
- "5300:3000"

altinn_localtest:
container_name: localtest
image: localtest:latest
restart: always
networks:
- altinntestlocal_network
ports:
- "5101:5101"
build:
context: .
environment:
- DOTNET_ENVIRONMENT=Podman
- ASPNETCORE_URLS=http://*:5101/
- GeneralSettings__BaseUrl=http://${TEST_DOMAIN:-local.altinn.cloud}:${ALTINN3LOCAL_PORT:-80}
- GeneralSettings__HostName=${TEST_DOMAIN:-local.altinn.cloud}
volumes:
- ./testdata:/testdata
- ${ALTINN3LOCALSTORAGE_PATH:-AltinnPlatformLocal}:/AltinnPlatformLocal

volumes:
AltinnPlatformLocal:
8 changes: 8 additions & 0 deletions src/appsettings.Podman.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"LocalPlatformSettings": {
"LocalAppMode": "http",
"LocalAppUrl": "http://host.containers.internal:5005",
"LocalTestingStorageBasePath": "/AltinnPlatformLocal/",
"LocalTestingStaticTestDataPath": "/testdata/"
}
}

0 comments on commit c55ae94

Please sign in to comment.