Skip to content

Commit f2a5e78

Browse files
author
Vadim Bogulean
committed
chore: add APP_VERSION build argument for dynamic version injection
1 parent f6c6890 commit f2a5e78

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
POSTGRES_PASSWORD="postgres_password"
22
FCDB_USER="fastcve_db_user"
33
FCDB_PASS="fastcve_db_pass"
4-
FASTCVE_DOCKER_IMG="binareio/fastcve:latest"
4+
FASTCVE_DOCKER_IMG="binareio/fastcve"
5+
FASTCVE_DOCKER_TAG="latest"
56
NVD_API_KEY=

.github/workflows/build-and-push.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
# Step 4: Build Docker Image with release and latest tags
2727
- name: Build Docker Image
2828
run: |
29-
docker build -t ${{ secrets.DOCKER_USERNAME }}/fastcve:${{ github.ref_name }} \
29+
docker build --build-arg APP_VERSION=${{ github.ref_name }} \
30+
-t ${{ secrets.DOCKER_USERNAME }}/fastcve:${{ github.ref_name }} \
3031
-t ${{ secrets.DOCKER_USERNAME }}/fastcve:latest .
3132
3233
# Step 5: Push Docker Image for both tags

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM postgres:16-alpine3.19
22

3-
ENV FCDB_HOME=/fastcve FCDB_NAME=vuln_db POSTGRES_PASSWORD=POSTGRES_PASSWORD FCDB_USER= FCDB_PASS=
4-
ENV PATH $PATH:${FCDB_HOME}
3+
ARG APP_VERSION=0.1.0
4+
5+
ENV APP_VERSION=${APP_VERSION} FCDB_HOME=/fastcve FCDB_NAME=vuln_db POSTGRES_PASSWORD= FCDB_USER= FCDB_PASS=
6+
ENV PATH=${FCDB_HOME}:$PATH
57

68
RUN apk add gcc g++ build-base python3-dev py3-pip
79

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
# Application Database service
44
#--------------------------------------------------------------------------
55
fastcve:
6-
image: "${FASTCVE_DOCKER_IMG}"
6+
image: "${FASTCVE_DOCKER_IMG}:${FASTCVE_DOCKER_TAG}"
77

88
container_name: fastcve
99

@@ -13,6 +13,9 @@ services:
1313
context: $PWD
1414
dockerfile: $PWD/Dockerfile
1515

16+
args:
17+
APP_VERSION: ${FASTCVE_DOCKER_TAG:-0.1.0}
18+
1619
environment:
1720
- INP_ENV_NAME=${INP_ENV_NAME}
1821
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}

src/web/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
from dependencies import get_app_cntxt
66
from web.routers.search import router as router_search
77
from web.models.search import StatusOutput
8+
import os
89

9-
app = FastAPI(title="FastCVE", description="fast, rich and API-based search for CVE and more (CPE, CWE, CAPEC)", version="0.1.0")
10+
version = os.getenv("APP_VERSION", "0.1.0")
11+
app = FastAPI(title="FastCVE", description="Fast, Rich and API-based search for CVE and more (CPE, CWE, CAPEC)", version=version)
1012

1113

1214
@app.get("/status", tags=['status'], name="DB status", response_model=StatusOutput)

0 commit comments

Comments
 (0)