Skip to content

Commit

Permalink
Merge pull request #181 from OpenConext/feature/docker_add_labels_and…
Browse files Browse the repository at this point in the history
…_env_vars

Docker: Add labels and env variables
  • Loading branch information
quartje authored Mar 4, 2024
2 parents 5abe623 + aefd80b commit aed9023
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: build-push-docker-image

#on: workflow_dispatch
on:
push:
branches: feature/docker_configs
workflow_dispatch:

jobs:
Expand All @@ -13,15 +10,26 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
tags: true

- name: Get the latest release
id: release
uses: robinraju/release-downloader@v1.7
uses: robinraju/release-downloader@v1.9
with:
latest: true
fileName: "*.tar.bz2"

- name: Get commit details for the tag from the latest release
id: commit_details
run: |
GIT_SHA=$(git rev-list -n 1 ${{ steps.release.outputs.tag_name }})
GIT_COMMIT_TIME=$(git show -s --format=%ci ${{ steps.release.outputs.tag_name }})
echo "::set-output name=sha::$GIT_SHA"
echo "::set-output name=commit_time::$GIT_COMMIT_TIME"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -35,14 +43,27 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set docker labels and tags
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/openconext/stepup-tiqr/stepup-tiqr
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=sha
type=raw,value=prod
- name: Build and push the Production image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
APP_VERSION=${{ steps.release.outputs.tag_name }}
GIT_SHA=${{ steps.commit_details.outputs.sha }}
GIT_COMMIT_TIME=${{ steps.commit_details.outputs.commit_time }}
file: docker/Dockerfile.prod
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/openconext/stepup-tiqr/stepup-tiqr:prod
ghcr.io/openconext/stepup-tiqr/stepup-tiqr:${{ github.sha }}
ghcr.io/openconext/stepup-tiqr/stepup-tiqr:${{ steps.release.outputs.tag_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 6 additions & 0 deletions docker/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest
ARG APP_VERSION
ARG GIT_SHA
ARG GIT_COMMIT_TIME
ENV OPENCONEXT_APP_VERSION=${APP_VERSION}
ENV OPENCONEXT_GIT_SHA=${GIT_SHA}
ENV OPENCONEXT_COMMIT_DATE=${GIT_COMMIT_TIME}
# Set the default workdir
WORKDIR /var/www/html

Expand Down

0 comments on commit aed9023

Please sign in to comment.