Docker Compose one command start #2042
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| workflow_dispatch: ~ | |
| push: | |
| branches: | |
| - master | |
| pull_request: ~ | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref_name != 'master' }} | |
| jobs: | |
| import: | |
| name: Import data | |
| strategy: | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Date | |
| id: get-date | |
| shell: bash | |
| run: | | |
| echo "date=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT | |
| - name: Cache data | |
| uses: actions/cache@v4 | |
| id: cache-data | |
| with: | |
| path: | | |
| data/berlin.osm.pbf | |
| data/filtered/berlin.osm.pbf | |
| key: data-${{ steps.get-date.outputs.date }}-berlin | |
| enableCrossOsArchive: true | |
| - name: Download Berlin | |
| if: ${{ steps.cache-data.outputs.cache-hit != 'true' }} | |
| run: | | |
| curl --location --fail --output data/berlin.osm.pbf https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf | |
| - name: Build database and image containers | |
| uses: docker/bake-action@v6 | |
| with: | |
| load: true | |
| targets: db,import | |
| set: | | |
| db.cache-from=type=gha,scope=db-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('db.cache-to=type=gha,mode=max,scope=db-{}', runner.arch) || '' }} | |
| import.cache-from=type=gha,scope=import-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('import.cache-to=type=gha,mode=max,scope=import-{}', runner.arch) || '' }} | |
| - name: Start database | |
| run: | | |
| docker compose up --no-build --wait db | |
| - name: Import data | |
| env: | |
| OSM2PGSQL_DATAFILE: berlin.osm.pbf | |
| run: | | |
| docker compose run --rm import import | |
| - name: Prepare and save database image | |
| run: | | |
| docker compose stop db | |
| DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')" | |
| docker commit "$DB_CONTAINER_ID" openrailwaymap-db | |
| docker save openrailwaymap-db > ${{ runner.temp }}/openrailwaymap-db.tar | |
| - name: Upload database artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ runner.arch }}-openrailwaymap-db | |
| path: ${{ runner.temp }}/openrailwaymap-db.tar | |
| test-import: | |
| name: Test import | |
| strategy: | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build import image | |
| run: | | |
| docker build --file import/Dockerfile --target test --tag import-test . | |
| - name: Run import tests | |
| run: | | |
| docker run --rm import-test | |
| test-api: | |
| name: Test API | |
| strategy: | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: | |
| - import | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download database artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ runner.arch }}-openrailwaymap-db | |
| path: ${{ runner.temp }} | |
| - name: Load database image | |
| run: | | |
| cat ${{ runner.temp }}/openrailwaymap-db.tar | docker load | |
| - name: Build API container | |
| uses: docker/bake-action@v6 | |
| with: | |
| load: true | |
| targets: api | |
| set: | | |
| api.cache-from=type=gha,scope=api-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('api.cache-to=type=gha,mode=max,scope=api-{}', runner.arch) || '' }} | |
| - name: Start database | |
| run: | | |
| docker compose up --no-build --wait --no-deps db | |
| - name: Start API | |
| run: | | |
| docker compose up --wait --no-build --no-deps api | |
| - name: Run API tests | |
| working-directory: api | |
| run: | | |
| docker run --rm --net host -v "$PWD/test/api.hurl:/hurl/api.hurl" ghcr.io/orange-opensource/hurl:6.1.1 --test --verbose --variable base_url=http://localhost:5000/api /hurl/api.hurl | |
| - name: Print logs | |
| if: always() | |
| run: | | |
| docker compose logs | |
| test-proxy: | |
| name: Test proxy | |
| strategy: | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: | |
| - import | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download database artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ runner.arch }}-openrailwaymap-db | |
| path: ${{ runner.temp }} | |
| - name: Load database image | |
| run: | | |
| cat ${{ runner.temp }}/openrailwaymap-db.tar | docker load | |
| - name: Build Martin and proxy containers | |
| uses: docker/bake-action@v6 | |
| with: | |
| load: true | |
| targets: martin,martin-proxy | |
| set: | | |
| martin.cache-from=type=gha,scope=martin-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('martin.cache-to=type=gha,mode=max,scope=martin-{}', runner.arch) || '' }} | |
| martin-proxy.cache-from=type=gha,scope=martin-proxy-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('martin-proxy.cache-to=type=gha,mode=max,scope=martin-proxy-{}', runner.arch) || '' }} | |
| - name: Start database | |
| run: | | |
| docker compose up --no-build --wait --no-deps db | |
| - name: Start tile server | |
| run: | | |
| docker compose up --no-build --detach --no-deps martin | |
| - name: Start web server | |
| run: | | |
| docker compose up --no-build --wait --no-deps martin-proxy | |
| - name: Run proxy tests | |
| working-directory: proxy | |
| run: | | |
| docker run --rm --net host -v "$PWD/test/proxy.hurl:/hurl/proxy.hurl" ghcr.io/orange-opensource/hurl:6.1.1 --test --verbose --variable base_url=http://localhost:8000 /hurl/proxy.hurl | |
| - name: Download preset | |
| if: always() | |
| run: | | |
| curl -sSf -o preset.zip http://localhost:8000/preset.zip | |
| - name: Store preset | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: ${{ runner.arch }}-presets | |
| path: preset.zip | |
| if-no-files-found: warn | |
| - name: Print logs | |
| if: always() | |
| run: | | |
| docker compose logs | |
| test-ui: | |
| name: Test UI | |
| strategy: | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: | |
| - test-proxy | |
| - test-api | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download database artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ runner.arch }}-openrailwaymap-db | |
| path: ${{ runner.temp }} | |
| - name: Load database image | |
| run: | | |
| cat ${{ runner.temp }}/openrailwaymap-db.tar | docker load | |
| - name: Build API, Martin and proxy containers | |
| uses: docker/bake-action@v6 | |
| with: | |
| load: true | |
| targets: api,martin,martin-proxy | |
| set: | | |
| api.cache-from=type=gha,scope=api-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('api.cache-to=type=gha,mode=max,scope=api-{}', runner.arch) || '' }} | |
| martin.cache-from=type=gha,scope=martin-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('martin.cache-to=type=gha,mode=max,scope=martin-{}', runner.arch) || '' }} | |
| martin-proxy.cache-from=type=gha,scope=martin-proxy-${{ runner.arch }} | |
| ${{ github.ref_name == 'master' && format('martin-proxy.cache-to=type=gha,mode=max,scope=martin-proxy-{}', runner.arch) || '' }} | |
| - name: Start database | |
| run: | | |
| docker compose up --no-build --wait --no-deps db | |
| - name: Start tile server | |
| run: | | |
| docker compose up --no-build --detach --no-deps martin | |
| - name: Start web server | |
| run: | | |
| docker compose up --no-build --wait --no-deps martin-proxy | |
| - name: Start API | |
| run: | | |
| docker compose up --wait --no-build --no-deps api | |
| - name: Run UI tests | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| working-directory: proxy/test/ui | |
| browser: ${{ runner.arch == 'X64' && 'chrome' || 'firefox' }} | |
| - name: Store screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: ${{ runner.arch }}-screenshots | |
| path: proxy/test/ui/cypress/screenshots | |
| if-no-files-found: warn |