From e45d3dae4e8940c088d9ea3e7f01cbad2e497e9c Mon Sep 17 00:00:00 2001 From: Ilya Egorov Date: Thu, 21 Nov 2024 19:22:55 +0300 Subject: [PATCH] ci: update env docker build (#159) Co-authored-by: Ilya Egorov --- .eslintrc.cjs | 7 ++++++- .github/workflows/deploy.yml | 8 ++++---- .prettierignore | 1 + Dockerfile | 21 +++++++++++++++++++-- helm/app/templates/deployment.yaml | 6 ------ helm/app/values.yaml | 6 ------ package-lock.json | 6 ++++-- package.json | 2 +- 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5129d4d..1e4e848 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -12,7 +12,12 @@ module.exports = { ecmaVersion: 2020, project: "./tsconfig.json", }, - ignorePatterns: ["*.cjs", "!.lintstagedrc.js", ".lintstagedrc.js", "next.config.js"], + ignorePatterns: [ + "*.cjs", + "!.lintstagedrc.js", + ".lintstagedrc.js", + "next.config.js", + ], plugins: ["@typescript-eslint"], root: true, env: { diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dd29f0d..e16885f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -65,6 +65,9 @@ jobs: sha=${{ github.sha }} sha_short=${{ env.GITHUB_SHA_SHORT }} app_env=${{ vars.APP_ENV }} + NEXT_PUBLIC_PROXY_KEY=${{ secrets.NEXT_PUBLIC_PROXY_KEY }} + NEXT_PUBLIC_MIXPANEL_TOKEN=${{ secrets.NEXT_PUBLIC_MIXPANEL_TOKEN }} + NEXT_PUBLIC_ANALYTICS_ENABLED=${{ secrets.NEXT_PUBLIC_ANALYTICS_ENABLED }} - name: Apply AWS k8s config run: aws eks update-kubeconfig --name ${{ vars.AWS_CLUSTER }} --region ${{ vars.AWS_REGION }} @@ -83,10 +86,7 @@ jobs: --set imageTag="${{ env.GITHUB_SHA_SHORT }}" \ --set host=${{ env.APP_DOMAIN }} \ --set appName=${{ vars.APP_NAME }} \ - --set ghcrSecret=${{ secrets.GHCR_SECRET }} \ - --set secrets.nextPublicProxyKey=${{ secrets.NEXT_PUBLIC_PROXY_KEY }} \ - --set secrets.nextPublicMixpanelToken=${{ secrets.NEXT_PUBLIC_MIXPANEL_TOKEN }} \ - --set secrets.nextPublicAnalyticsEnabled=${{ secrets.NEXT_PUBLIC_ANALYTICS_ENABLED }} + --set ghcrSecret=${{ secrets.GHCR_SECRET }} - name: Verify deployment run: | diff --git a/.prettierignore b/.prettierignore index ab86c3d..03d4beb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ /helm +.github/workflows diff --git a/Dockerfile b/Dockerfile index cabec61..80174ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,27 @@ -FROM node:21-alpine AS base +FROM node:21-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm install COPY . . -RUN npm run build + +ARG NEXT_PUBLIC_PROXY_KEY=redacted_next_public_proxy_key +ARG NEXT_PUBLIC_MIXPANEL_TOKEN=redacted_next_public_mixpanel_token +ARG NEXT_PUBLIC_ANALYTICS_ENABLED=false + +RUN NEXT_PUBLIC_PROXY_KEY=${NEXT_PUBLIC_PROXY_KEY} \ + NEXT_PUBLIC_MIXPANEL_TOKEN=${NEXT_PUBLIC_MIXPANEL_TOKEN} \ + NEXT_PUBLIC_ANALYTICS_ENABLED=${NEXT_PUBLIC_ANALYTICS_ENABLED} \ + npm run build + + +FROM node:21-alpine AS runtime + +WORKDIR /app +COPY --from=build /app/.next ./.next +COPY package*.json ./ + +RUN npm install EXPOSE 3000 CMD ["npm", "start"] diff --git a/helm/app/templates/deployment.yaml b/helm/app/templates/deployment.yaml index 401295f..f663822 100644 --- a/helm/app/templates/deployment.yaml +++ b/helm/app/templates/deployment.yaml @@ -36,12 +36,6 @@ spec: value: {{ .Values.deployEnv }} - name: APP_VERSION value: {{ .Values.appVersion | quote }} - - name: NEXT_PUBLIC_PROXY_KEY - value: {{ .Values.secrets.nextPublicProxyKey | quote }} - - name: NEXT_PUBLIC_MIXPANEL_TOKEN - value: {{ .Values.secrets.nextPublicMixpanelToken | quote }} - - name: NEXT_PUBLIC_ANALYTICS_ENABLED - value: {{ .Values.secrets.nextPublicAnalyticsEnabled | quote }} ports: - containerPort: {{ .Values.containerPort }} resources: diff --git a/helm/app/values.yaml b/helm/app/values.yaml index 1ff7425..b95eae1 100644 --- a/helm/app/values.yaml +++ b/helm/app/values.yaml @@ -34,9 +34,3 @@ certIssuingMode: false # http publicService: true sslRedirect: false - - -secrets: - nextPublicProxyKey: "redacted_proxy_key" - nextPublicMixpanelToken: "redacted_mixpanel_token" - nextPublicAnalyticsEnabled: "true" diff --git a/package-lock.json b/package-lock.json index 1f2a531..8e34d21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -84,7 +84,7 @@ "lint-staged": "^15.2.10", "monaco-editor-webpack-plugin": "^7.0.1", "next-transpile-modules": "^10.0.0", - "prettier": "^3.3.2" + "prettier": "^3.3.3" } }, "node_modules/@ant-design/colors": { @@ -8534,7 +8534,9 @@ } }, "node_modules/prettier": { - "version": "3.3.2", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 0d8c13d..1b7aa04 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,6 @@ "lint-staged": "^15.2.10", "monaco-editor-webpack-plugin": "^7.0.1", "next-transpile-modules": "^10.0.0", - "prettier": "^3.3.2" + "prettier": "^3.3.3" } }