From a9434307f13200900e5b19c23381e295fd96727b Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Thu, 20 Apr 2023 09:47:35 -0400 Subject: [PATCH] Adding version number env param to image --- .github/workflows/image-push.yml | 2 ++ Dockerfile | 6 ++++++ src/server.py | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image-push.yml b/.github/workflows/image-push.yml index c1f2022..a169404 100644 --- a/.github/workflows/image-push.yml +++ b/.github/workflows/image-push.yml @@ -47,6 +47,8 @@ jobs: uses: docker/build-push-action@v3 with: push: true + build-args: | + APP_VERSION=${{ steps.get_version.outputs.VERSION }} tags: | ${{ env.REGISTRY }}:latest ${{ env.REGISTRY }}:${{ steps.get_version.outputs.VERSION }} diff --git a/Dockerfile b/Dockerfile index afdf3d4..356b7cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,12 @@ RUN apt-get clean # get some credit LABEL maintainer="powen@renci.org" +# get the build argument that has the version +ARG APP_VERSION=$(APP_VERSION) + +# now add the version arg value into a ENV param +ENV APP_VERSION=$APP_VERSION + # Copy in just the requirements first for caching purposes COPY requirements.txt requirements.txt RUN pip install -r requirements.txt diff --git a/src/server.py b/src/server.py index ca80af2..0f7f6ac 100644 --- a/src/server.py +++ b/src/server.py @@ -10,6 +10,7 @@ """ import json +import os import re from pathlib import Path @@ -23,7 +24,7 @@ from src.common.pg_impl import PGImplementation # set the app version -APP_VERSION = 'v0.3.11' +APP_VERSION = os.getenv('APP_VERSION', 'Version number not set') # declare the FastAPI details APP = FastAPI(title='APSVIZ Settings', version=APP_VERSION)