From 6294af8789a8a1c666d4608d9a1f6c8d602ebbc9 Mon Sep 17 00:00:00 2001 From: Jakob Miksch Date: Sat, 6 Jul 2024 12:52:13 +0200 Subject: [PATCH] Build docker image in CI --- .github/workflows/build-container.yml | 55 +++++++++++++++++++++++++++ sandbox/Dockerfile => Dockerfile | 0 docs/src/qsa-api/installation.md | 6 +-- sandbox/docker-compose.yml | 2 +- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-container.yml rename sandbox/Dockerfile => Dockerfile (100%) diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml new file mode 100644 index 0000000..ddb47de --- /dev/null +++ b/.github/workflows/build-container.yml @@ -0,0 +1,55 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Install Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push Docker Image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/sandbox/Dockerfile b/Dockerfile similarity index 100% rename from sandbox/Dockerfile rename to Dockerfile diff --git a/docs/src/qsa-api/installation.md b/docs/src/qsa-api/installation.md index 96574b4..dda09f4 100644 --- a/docs/src/qsa-api/installation.md +++ b/docs/src/qsa-api/installation.md @@ -1,6 +1,6 @@ # QSA REST API : installation -From sources: +## From sources ```` shell $ cd qsa-api @@ -10,6 +10,6 @@ $ . venv/bin/activate (venv)$ poetry install ```` -Binary distributions: +## Docker image -TODO : provide a docker image on Dockerhub +A prebuilt image can be found on `ghcr.io/pblottiere/qsa`. Otherwise the image can be manually be built using: `docker build -t my-custom-qsa-image .` See [Sandbox](sandbox/) for details how to use it. diff --git a/sandbox/docker-compose.yml b/sandbox/docker-compose.yml index 07cfe89..1aff09c 100644 --- a/sandbox/docker-compose.yml +++ b/sandbox/docker-compose.yml @@ -18,7 +18,7 @@ services: image: pblottiere/qsa build: context: .. - dockerfile: sandbox/Dockerfile + dockerfile: Dockerfile volumes: - ./dem.tif:/dem.tif - ./data.gpkg:/data.gpkg