docker: pass in build-args, add $NOW

This commit is contained in:
Ralf Vogler 2023-08-27 23:32:56 +02:00
parent 2eb17a1419
commit 8a010dbcc7
3 changed files with 21 additions and 6 deletions

View file

@ -20,6 +20,11 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set environment variables
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
@ -29,6 +34,7 @@ jobs:
-
name: Login to Docker Hub
uses: docker/login-action@v2
if: ${{ secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@ -44,8 +50,12 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
push: true
build-args: |
COMMIT=${{ github.sha }}
BRANCH=${{ env.BRANCH }}
NOW=${{ env.NOW }}
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
tags: |
voglerr/free-games-claimer:latest
ghcr.io/vogler/free-games-claimer:latest

View file

@ -60,19 +60,23 @@ COPY . .
RUN dos2unix *.sh && chmod +x *.sh
COPY docker-entrypoint.sh /usr/local/bin/
ARG COMMIT=""
ARG BRANCH=""
ARG NOW=""
ENV COMMIT=${COMMIT}
ENV BRANCH=${BRANCH}
ENV NOW=${NOW}
LABEL org.opencontainers.image.title="free-games-claimer" \
org.opencontainers.image.name="free-games-claimer" \
org.opencontainers.image.description="Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG" \
org.opencontainers.image.url="https://github.com/vogler/free-games-claimer" \
org.opencontainers.image.source="https://github.com/vogler/free-games-claimer" \
org.opencontainers.image.revision=${COMMIT_SHA} \
org.opencontainers.image.revision=${COMMIT} \
org.opencontainers.image.ref.name=${BRANCH} \
org.opencontainers.image.base.name="ubuntu:jammy" \
org.opencontainers.image.version="latest"
ENV COMMIT_SHA=${COMMIT_SHA}
ENV BRANCH=${BRANCH}
# Configure VNC via environment variables:
ENV VNC_PORT 5900
ENV NOVNC_PORT 6080

View file

@ -2,8 +2,9 @@
set -eo pipefail # exit on error, error on any fail in pipe (not just last cmd); add -x to print each cmd; see gist bash_strict_mode.md
echo "Version: https://github.com/vogler/free-games-claimer/tree/${COMMIT_SHA}"
echo "Version: https://github.com/vogler/free-games-claimer/tree/${COMMIT}"
[ ! -z $BRANCH ] && [ $BRANCH != "main" ] && echo "Branch: ${BRANCH}"
echo "Build: $NOW"
# Remove chromium profile lock.
# When running in docker and then killing it, on the next run chromium displayed a dialog to unlock the profile which made the script time out.