From 6fe14409661e11210541151f1dba0faf803ea616 Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Fri, 11 Aug 2023 08:41:41 +0200 Subject: [PATCH] ci: exclude environment from image (#332) --- .../actions/build-and-deploy-api/action.yml | 16 +++++------ .github/workflows/ci.yml | 16 ++++------- apps/api/webpack.config.js | 7 ----- package-lock.json | 1 - package.json | 27 +++++++++---------- 5 files changed, 26 insertions(+), 41 deletions(-) diff --git a/.github/actions/build-and-deploy-api/action.yml b/.github/actions/build-and-deploy-api/action.yml index 85fe6ba6..4ecc942c 100644 --- a/.github/actions/build-and-deploy-api/action.yml +++ b/.github/actions/build-and-deploy-api/action.yml @@ -34,14 +34,6 @@ outputs: runs: using: "composite" steps: - - name: Set environment - run: envsubst < apps/api/src/.env.template > apps/api/src/.env - env: - MONGODB_URI: ${{ inputs.mongoUri }} - ENVIRONMENT_NAME: ${{ inputs.slot }} - RELEASE_VERSION: ${{ inputs.releaseVersion }} - SENTRY_KEY: ${{ inputs.sentryKey }} - shell: bash - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to GitHub Container Registry @@ -69,6 +61,14 @@ runs: ghcr.io/kordis-leitstelle/kordis-api:${{ inputs.releaseVersion}} cache-from: type=gha cache-to: type=gha,mode=max + - name: Set environment for Azure deployment + run: envsubst < apps/api/src/.env.template > dist/apps/api/.env + env: + MONGODB_URI: ${{ inputs.mongoUri }} + ENVIRONMENT_NAME: ${{ inputs.slot }} + RELEASE_VERSION: ${{ inputs.releaseVersion }} + SENTRY_KEY: ${{ inputs.sentryKey }} + shell: bash - name: Deploy API id: wa-deployment uses: azure/webapps-deploy@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc109020..ee05a167 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,25 +47,19 @@ jobs: RELEASE_VERSION: ${{ github.sha }} API_URL: http://localhost:3000/ OAUTH_CONFIG: undefined - - name: Create API Environment File - run: | - envsubst < apps/api/src/.env.template > apps/api/src/.env - echo "PORT=3000" >> .env - env: - MONGODB_URI: mongodb://127.0.0.1:27017/e2edb - ENVIRONMENT_NAME: 'ci' - RELEASE_VERSION: ${{ github.sha }} - SENTRY_KEY: ${{ secrets.SENTRY_KEY }} - - name: Build run: npx nx run-many -t build --all --parallel=3 - - name: Start and prepare MongoDB for E2Es run: ./tools/db/kordis-db.sh init e2edb - name: Run E2Es run: npm run serve:all:prod & (npx wait-on tcp:3000 && npx wait-on http://localhost:4200 && npx nx e2e spa-e2e) env: E2E_BASE_URL: http://localhost:4200/ + MONGODB_URI: mongodb://127.0.0.1:27017/e2edb + ENVIRONMENT_NAME: 'ci' + RELEASE_VERSION: ${{ github.sha }} + SENTRY_KEY: ${{ secrets.SENTRY_KEY }} + PORT: 3000 - uses: actions/upload-artifact@v3 if: failure() with: diff --git a/apps/api/webpack.config.js b/apps/api/webpack.config.js index d85b8aff..37acc815 100644 --- a/apps/api/webpack.config.js +++ b/apps/api/webpack.config.js @@ -1,12 +1,5 @@ const { composePlugins, withNx } = require('@nx/webpack'); -const CopyPlugin = require('copy-webpack-plugin'); module.exports = composePlugins(withNx(), (config) => { - config.plugins.push( - new CopyPlugin({ - patterns: [{ from: 'src/.env', to: '.', noErrorOnMissing: true }], - }), - ); - return config; }); diff --git a/package-lock.json b/package-lock.json index 44888b9f..28259733 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,7 +91,6 @@ "@typescript-eslint/parser": "5.61.0", "autoprefixer": "^10.4.0", "cobertura-merge": "^1.0.4", - "copy-webpack-plugin": "^11.0.0", "eslint": "8.46.0", "eslint-config-prettier": "8.10.0", "eslint-plugin-cypress": "^2.10.3", diff --git a/package.json b/package.json index 4705c55e..a9fb1408 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,15 @@ "@nestjs/schematics": "10.0.1", "@nestjs/testing": "10.0.3", "@ngneat/spectator": "^15.0.0", + "@nx/angular": "16.6.0", + "@nx/eslint-plugin": "16.6.0", + "@nx/jest": "16.6.0", + "@nx/js": "16.6.0", + "@nx/linter": "16.6.0", + "@nx/nest": "16.6.0", + "@nx/node": "16.6.0", + "@nx/webpack": "16.6.0", + "@nx/workspace": "16.6.0", "@playwright/test": "^1.26.0", "@schematics/angular": "16.1.1", "@total-typescript/ts-reset": "^0.3.7", @@ -43,7 +52,6 @@ "@typescript-eslint/parser": "5.61.0", "autoprefixer": "^10.4.0", "cobertura-merge": "^1.0.4", - "copy-webpack-plugin": "^11.0.0", "eslint": "8.46.0", "eslint-config-prettier": "8.10.0", "eslint-plugin-cypress": "^2.10.3", @@ -66,16 +74,7 @@ "ts-jest": "29.1.0", "ts-node": "10.9.1", "typescript": "5.1.3", - "wait-on": "^7.0.1", - "@nx/workspace": "16.6.0", - "@nx/js": "16.6.0", - "@nx/eslint-plugin": "16.6.0", - "@nx/jest": "16.6.0", - "@nx/linter": "16.6.0", - "@nx/node": "16.6.0", - "@nx/nest": "16.6.0", - "@nx/webpack": "16.6.0", - "@nx/angular": "16.6.0" + "wait-on": "^7.0.1" }, "dependencies": { "@angular/animations": "16.1.2", @@ -96,14 +95,14 @@ "@nestjs/cqrs": "^10.0.1", "@nestjs/graphql": "^12.0.3", "@nestjs/mongoose": "^10.0.0", - "@opentelemetry/instrumentation-graphql": "^0.35.0", "@nestjs/platform-express": "10.0.3", + "@opentelemetry/instrumentation-graphql": "^0.35.0", + "@opentelemetry/instrumentation-mongoose": "^0.33.0", "@opentelemetry/instrumentation-pino": "^0.34.0", + "@opentelemetry/sdk-node": "^0.41.0", "@opentelemetry/sdk-trace-base": "^1.14.0", "@sentry/angular-ivy": "^7.57.0", "@sentry/integrations": "^7.62.0", - "@opentelemetry/instrumentation-mongoose": "^0.33.0", - "@opentelemetry/sdk-node": "^0.41.0", "@sentry/node": "^7.62.0", "@sentry/opentelemetry-node": "^7.62.0", "@sentry/profiling-node": "^1.1.2",