From 95af82963f016a836b76ccdcffb4afb0ddcd7b06 Mon Sep 17 00:00:00 2001 From: Joel Biddle Date: Tue, 3 Oct 2023 05:55:36 +0000 Subject: [PATCH 1/5] Add version tags to Docker image & display on frontend --- .../workflows/build-docker-image-to-prod.yml | 26 ++++++++++++++++--- frontend/src/layouts/AppLayout/AppLayout.tsx | 6 +++++ frontend/src/version.ts | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 frontend/src/version.ts diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index 116ca0cf9..dddcf8159 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -39,7 +39,10 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} load: true context: backend - tags: infisical/backend:test + tags: | + infisical/backend:${{ steps.extract_version.outputs.version }} + labels: | + version=${{ steps.extract_version.outputs.version }} - name: ⏻ Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -58,9 +61,10 @@ jobs: context: backend tags: | infisical/backend:${{ steps.commit.outputs.short }} - infisical/backend:latest infisical/backend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 + labels: | + version=${{ steps.extract_version.outputs.version }} frontend-image: name: Build frontend image @@ -90,9 +94,22 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} project: 64mmf0n610 context: frontend - tags: infisical/frontend:test + tags: | + infisical/frontend:${{ steps.extract_version.outputs.version }} build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + labels: | + version=${{ steps.extract_version.outputs.version }} + - name: 🛠️ Create or update Infisical version in version.ts file + run: | + version='${{ steps.extract_version.outputs.version }}' + file='frontend/src/version.ts' + touch "$file" + if grep -q "export const CURRENT_INFISICAL_VERSION = '.*';" "$file"; then + sed -i "s/export const CURRENT_INFISICAL_VERSION = '.*';/export const CURRENT_INFISICAL_VERSION = '$version';/" "$file" + else + echo "export const INFISICAL_VERSION = '$version';" >> "$file" + fi - name: ⏻ Spawn frontend container run: | docker run -d --rm --name infisical-frontend-test infisical/frontend:test @@ -111,8 +128,9 @@ jobs: context: frontend tags: | infisical/frontend:${{ steps.commit.outputs.short }} - infisical/frontend:latest infisical/frontend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + labels: | + version=${{ steps.extract_version.outputs.version }} \ No newline at end of file diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 8dd5f12ab..ed86b19b7 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -21,6 +21,7 @@ import { faCheck, faEnvelope, faInfinity, + faInfo, faMobile, faPlus, faQuestion @@ -68,6 +69,7 @@ import { useLogoutUser, useUploadWsKey } from "@app/hooks/api"; +import { CURRENT_INFISICAL_VERSION } from "@app/version" interface LayoutProps { children: React.ReactNode; @@ -696,6 +698,10 @@ export const AppLayout = ({ children }: LayoutProps) => { )} +
+ + Current version: {CURRENT_INFISICAL_VERSION} +
diff --git a/frontend/src/version.ts b/frontend/src/version.ts new file mode 100644 index 000000000..a170fa857 --- /dev/null +++ b/frontend/src/version.ts @@ -0,0 +1 @@ +export const CURRENT_INFISICAL_VERSION = "v1.1.1"; // placeholder - dynamically updated on prod build \ No newline at end of file From 390c2cc4d9014db7968aec38696245d0a636ddf4 Mon Sep 17 00:00:00 2001 From: Joel Biddle Date: Wed, 4 Oct 2023 02:03:17 +0000 Subject: [PATCH 2/5] Changed to pass build arg & create NEXT envar --- .github/workflows/build-docker-image-to-prod.yml | 12 ++---------- frontend/Dockerfile | 5 ++++- frontend/src/layouts/AppLayout/AppLayout.tsx | 3 +-- frontend/src/version.ts | 1 - 4 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 frontend/src/version.ts diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index dddcf8159..3d3994e29 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -98,18 +98,9 @@ jobs: infisical/frontend:${{ steps.extract_version.outputs.version }} build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} labels: | version=${{ steps.extract_version.outputs.version }} - - name: 🛠️ Create or update Infisical version in version.ts file - run: | - version='${{ steps.extract_version.outputs.version }}' - file='frontend/src/version.ts' - touch "$file" - if grep -q "export const CURRENT_INFISICAL_VERSION = '.*';" "$file"; then - sed -i "s/export const CURRENT_INFISICAL_VERSION = '.*';/export const CURRENT_INFISICAL_VERSION = '$version';/" "$file" - else - echo "export const INFISICAL_VERSION = '$version';" >> "$file" - fi - name: ⏻ Spawn frontend container run: | docker run -d --rm --name infisical-frontend-test infisical/frontend:test @@ -132,5 +123,6 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} labels: | version=${{ steps.extract_version.outputs.version }} \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 49cbd3024..4b3c0125f 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,7 @@ ARG POSTHOG_HOST=https://app.posthog.com ARG POSTHOG_API_KEY=posthog-api-key ARG INTERCOM_ID=intercom-id +ARG NEXT_INFISICAL_PLATFORM_VERSION=next-infisical-platform-version FROM node:16-alpine AS deps # Install dependencies only when needed. Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. @@ -13,7 +14,6 @@ COPY package.json package-lock.json next.config.js ./ # Install dependencies RUN npm ci --only-production --ignore-scripts - # Rebuild the source code only when needed FROM node:16-alpine AS builder WORKDIR /app @@ -52,6 +52,9 @@ ENV NEXT_PUBLIC_POSTHOG_API_KEY=$POSTHOG_API_KEY \ ARG INTERCOM_ID ENV NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID \ BAKED_NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID +ARG NEXT_INFISICAL_PLATFORM_VERSION +ENV NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION=$NEXT_INFISICAL_PLATFORM_VERSION \ + BAKED_NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION=$NEXT_INFISICAL_PLATFORM_VERSION COPY --chown=nextjs:nodejs --chmod=555 scripts ./scripts COPY --from=builder /app/public ./public diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index ed86b19b7..04b80664a 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -69,7 +69,6 @@ import { useLogoutUser, useUploadWsKey } from "@app/hooks/api"; -import { CURRENT_INFISICAL_VERSION } from "@app/version" interface LayoutProps { children: React.ReactNode; @@ -700,7 +699,7 @@ export const AppLayout = ({ children }: LayoutProps) => { )}
- Current version: {CURRENT_INFISICAL_VERSION} + Platform Version: {process.env.NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION || "N/A"}
diff --git a/frontend/src/version.ts b/frontend/src/version.ts deleted file mode 100644 index a170fa857..000000000 --- a/frontend/src/version.ts +++ /dev/null @@ -1 +0,0 @@ -export const CURRENT_INFISICAL_VERSION = "v1.1.1"; // placeholder - dynamically updated on prod build \ No newline at end of file From 726f38c15f25b8c993bab487a8005ba4c8a0aba4 Mon Sep 17 00:00:00 2001 From: Joel Biddle Date: Wed, 4 Oct 2023 04:50:16 +0000 Subject: [PATCH 3/5] Resolve review comments --- .github/workflows/build-docker-image-to-prod.yml | 14 +++----------- frontend/src/layouts/AppLayout/AppLayout.tsx | 11 +++++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index 3d3994e29..c6b87345c 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -40,9 +40,7 @@ jobs: load: true context: backend tags: | - infisical/backend:${{ steps.extract_version.outputs.version }} - labels: | - version=${{ steps.extract_version.outputs.version }} + infisical/backend:test - name: ⏻ Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -63,8 +61,6 @@ jobs: infisical/backend:${{ steps.commit.outputs.short }} infisical/backend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 - labels: | - version=${{ steps.extract_version.outputs.version }} frontend-image: name: Build frontend image @@ -95,12 +91,10 @@ jobs: project: 64mmf0n610 context: frontend tags: | - infisical/frontend:${{ steps.extract_version.outputs.version }} + infisical/frontend:test build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} - labels: | - version=${{ steps.extract_version.outputs.version }} - name: ⏻ Spawn frontend container run: | docker run -d --rm --name infisical-frontend-test infisical/frontend:test @@ -123,6 +117,4 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} - labels: | - version=${{ steps.extract_version.outputs.version }} \ No newline at end of file + NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} \ No newline at end of file diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 04b80664a..4445ea7ff 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -123,6 +123,7 @@ export const AppLayout = ({ children }: LayoutProps) => { const createWs = useCreateWorkspace(); const uploadWsKey = useUploadWsKey(); const addWsUser = useAddUserToWs(); + const infisicalPlatformVersion = process.env.NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION; const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "addNewWs", @@ -697,10 +698,12 @@ export const AppLayout = ({ children }: LayoutProps) => { )} -
- - Platform Version: {process.env.NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION || "N/A"} -
+ {infisicalPlatformVersion && ( +
+ + Platform Version: {infisicalPlatformVersion} +
+ )} From 14b8c2c12afcd5cd170e8195103bae5009f34835 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Wed, 4 Oct 2023 14:29:36 -0400 Subject: [PATCH 4/5] remove unrelated changes --- .github/workflows/build-docker-image-to-prod.yml | 9 ++++----- frontend/Dockerfile | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index c6b87345c..60a56e9e5 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -39,8 +39,7 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} load: true context: backend - tags: | - infisical/backend:test + tags: infisical/backend:test - name: ⏻ Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -90,8 +89,7 @@ jobs: token: ${{ secrets.DEPOT_PROJECT_TOKEN }} project: 64mmf0n610 context: frontend - tags: | - infisical/frontend:test + tags: infisical/frontend:test build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} @@ -113,8 +111,9 @@ jobs: context: frontend tags: | infisical/frontend:${{ steps.commit.outputs.short }} + infisical/frontend:latest infisical/frontend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} \ No newline at end of file + NEXT_INFISICAL_PLATFORM_VERSION=${{ steps.extract_version.outputs.version }} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 4b3c0125f..2060c214a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -53,8 +53,7 @@ ARG INTERCOM_ID ENV NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID \ BAKED_NEXT_PUBLIC_INTERCOM_ID=$INTERCOM_ID ARG NEXT_INFISICAL_PLATFORM_VERSION -ENV NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION=$NEXT_INFISICAL_PLATFORM_VERSION \ - BAKED_NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION=$NEXT_INFISICAL_PLATFORM_VERSION +ENV NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION=$NEXT_INFISICAL_PLATFORM_VERSION COPY --chown=nextjs:nodejs --chmod=555 scripts ./scripts COPY --from=builder /app/public ./public From d3026a98d8c738488fa617fc07c38db93d6a830b Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Wed, 4 Oct 2023 14:57:30 -0400 Subject: [PATCH 5/5] add back infisical/backend:latest --- .github/workflows/build-docker-image-to-prod.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker-image-to-prod.yml b/.github/workflows/build-docker-image-to-prod.yml index 60a56e9e5..bea66e3fc 100644 --- a/.github/workflows/build-docker-image-to-prod.yml +++ b/.github/workflows/build-docker-image-to-prod.yml @@ -58,6 +58,7 @@ jobs: context: backend tags: | infisical/backend:${{ steps.commit.outputs.short }} + infisical/backend:latest infisical/backend:${{ steps.extract_version.outputs.version }} platforms: linux/amd64,linux/arm64