From b37ee3f94c65add55cf898fc0670d556055af0ec Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Wed, 9 Jul 2025 03:04:22 -0700 Subject: [PATCH 1/4] Add version, hash, and environment as build variables --- .gitea/workflows/build-production.yaml | 4 ++++ .gitea/workflows/build-staging.yaml | 4 ++++ Dockerfile | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/.gitea/workflows/build-production.yaml b/.gitea/workflows/build-production.yaml index f146779..cd928c2 100644 --- a/.gitea/workflows/build-production.yaml +++ b/.gitea/workflows/build-production.yaml @@ -52,6 +52,10 @@ jobs: gitea.perren.cloud/caperren/${{ needs.determine_version.outputs.repo_name }}:${{ needs.determine_version.outputs.repo_version_hash }} gitea.perren.cloud/caperren/${{ needs.determine_version.outputs.repo_name }}:${{ needs.determine_version.outputs.project_version }} gitea.perren.cloud/caperren/caperren-com:latest + build-args: | + REPO_VERSION_HASH=${{ needs.determine_version.outputs.repo_version_hash }} + PROJECT_VERSION=${{ needs.determine_version.outputs.project_version }} + BUILD_ENVIRONMENT=production test: runs-on: ubuntu-latest diff --git a/.gitea/workflows/build-staging.yaml b/.gitea/workflows/build-staging.yaml index c05d138..7242d5c 100644 --- a/.gitea/workflows/build-staging.yaml +++ b/.gitea/workflows/build-staging.yaml @@ -50,6 +50,10 @@ jobs: push: true tags: | gitea.perren.cloud/caperren/caperren-com:latest-staging + build-args: | + REPO_VERSION_HASH=${{ needs.determine_version.outputs.repo_version_hash }} + PROJECT_VERSION=${{ needs.determine_version.outputs.project_version }} + BUILD_ENVIRONMENT=staging test: runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 551a47c..dad6eac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,14 @@ FROM base AS build-deps RUN npm install FROM build-deps AS build + COPY . . + +ARG REPO_VERSION_HASH +ARG PROJECT_VERSION + +RUN echo $"REPO_VERSION_HASH=${REPO_VERSION_HASH} \n\ + PROJECT_VERSION=${PROJECT_VERSION}" >> .env RUN npm run build FROM httpd:latest AS runtime From 3ba6db7f83eebfd993e95a38bcf6797587ec05ed Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Wed, 9 Jul 2025 03:06:30 -0700 Subject: [PATCH 2/4] Make variables public --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dad6eac..01cd830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,8 @@ COPY . . ARG REPO_VERSION_HASH ARG PROJECT_VERSION -RUN echo $"REPO_VERSION_HASH=${REPO_VERSION_HASH} \n\ - PROJECT_VERSION=${PROJECT_VERSION}" >> .env +RUN echo $"PUBLIC_REPO_VERSION_HASH=${REPO_VERSION_HASH} \n\ + PUBLIC_PROJECT_VERSION=${PROJECT_VERSION}" >> .env RUN npm run build FROM httpd:latest AS runtime From e4a87c39418421f2566fecdf3fad0c3220d45a9a Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Wed, 9 Jul 2025 03:09:49 -0700 Subject: [PATCH 3/4] Deployment needs sleep after stopping --- .gitea/workflows/build-production.yaml | 1 + .gitea/workflows/build-staging.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitea/workflows/build-production.yaml b/.gitea/workflows/build-production.yaml index cd928c2..16578ff 100644 --- a/.gitea/workflows/build-production.yaml +++ b/.gitea/workflows/build-production.yaml @@ -86,6 +86,7 @@ jobs: -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '"caperren-com"' + sleep 5 - name: Start App run: | curl -k -X 'POST' \ diff --git a/.gitea/workflows/build-staging.yaml b/.gitea/workflows/build-staging.yaml index 7242d5c..0eaeac2 100644 --- a/.gitea/workflows/build-staging.yaml +++ b/.gitea/workflows/build-staging.yaml @@ -76,6 +76,7 @@ jobs: "name": "caperren-com-stg", "options": {} }' + - name: Stop App run: | curl -k -X 'POST' \ @@ -84,6 +85,7 @@ jobs: -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '"caperren-com-stg"' + sleep 5 - name: Start App run: | curl -k -X 'POST' \ From 594bc9bc4f49e25d9a6ef66d35ed133d73b28254 Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Wed, 9 Jul 2025 03:12:21 -0700 Subject: [PATCH 4/4] No sleep, just need to call start and not stop... --- .gitea/workflows/build-production.yaml | 3 +-- .gitea/workflows/build-staging.yaml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build-production.yaml b/.gitea/workflows/build-production.yaml index 16578ff..84acd53 100644 --- a/.gitea/workflows/build-production.yaml +++ b/.gitea/workflows/build-production.yaml @@ -86,11 +86,10 @@ jobs: -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '"caperren-com"' - sleep 5 - name: Start App run: | curl -k -X 'POST' \ - 'https://caperren.com:444/api/v2.0/app/stop' \ + 'https://caperren.com:444/api/v2.0/app/start' \ -H 'accept: */*' \ -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \ diff --git a/.gitea/workflows/build-staging.yaml b/.gitea/workflows/build-staging.yaml index 0eaeac2..a703610 100644 --- a/.gitea/workflows/build-staging.yaml +++ b/.gitea/workflows/build-staging.yaml @@ -85,11 +85,10 @@ jobs: -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '"caperren-com-stg"' - sleep 5 - name: Start App run: | curl -k -X 'POST' \ - 'https://caperren.com:444/api/v2.0/app/stop' \ + 'https://caperren.com:444/api/v2.0/app/start' \ -H 'accept: */*' \ -H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \ -H 'Content-Type: application/json' \