diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..8995c05 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,19 @@ +name: Run Docker test + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + docker-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Run Docker integration tests + run: | + curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/4.0.0/hurl_4.0.0_amd64.deb + sudo dpkg -i hurl_4.0.0_amd64.deb + bin/integration.sh http://localhost:3000/auth diff --git a/README.md b/README.md index 1572e0c..54c7103 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The server will be available at . ### Deployment using Docker Compose -TODO. +The project contains an example [Docker Compose file](docker-compose.yml) which can be used as a basis for deploying the application with Docker Compose. For more information on how to modify the file for this purpose, see ["Use Compose in production"](https://docs.docker.com/compose/production/). ## License diff --git a/bin/integration.sh b/bin/integration.sh new file mode 100644 index 0000000..2038b93 --- /dev/null +++ b/bin/integration.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +wait_for_url () { + echo "Testing $1..." + printf 'GET %s\nHTTP 200' "$1" | hurl --retry "$2" > /dev/null; + return 0 +} + +echo "Starting container..." +docker compose up --detach --build + +echo "Waiting for server to be ready..." +wait_for_url "$1" 60 + +echo "Stopping container..." +docker compose down diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b701e37 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + idrc-cms-authenticator: + build: . + container_name: "auth-incd-ca" + env_file: .env.test + ports: + - "3000:3000"