From dbd517380cecbf8c8b6fd10a48e71d8ba5fd0356 Mon Sep 17 00:00:00 2001 From: Torben Brenner Date: Mon, 30 Oct 2023 12:20:57 +0100 Subject: [PATCH] build: added separate develop image --- .github/workflows/docker-develop.yml | 22 ++++++++++++++++++++++ .github/workflows/docker.yml | 2 ++ Dockerfile | 5 +++-- packages/demo/src/AppCCP.svelte | 8 ++++++-- packages/lib/src/classes/spot.ts | 4 ++-- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker-develop.yml diff --git a/.github/workflows/docker-develop.yml b/.github/workflows/docker-develop.yml new file mode 100644 index 0000000..8c0fd6c --- /dev/null +++ b/.github/workflows/docker-develop.yml @@ -0,0 +1,22 @@ +name: Build and Push Develop Image samply/lens-web-components + +on: + push: + branches: + - develop + pull_request: + branches: + - develop +jobs: + build: + # This workflow defines how a samply docker image is built, tested and published. + # Visit: https://github.com/samply/github-workflows/blob/main/.github/workflows/docker-ci.yml, for more information + uses: samply/github-workflows/.github/workflows/docker-ci.yml@main + with: + image-name: "samply/lens-web-components" + build-args: | + TARGET_ENVIRONMENT=staging + # This passes the secrets from calling workflow to the called workflow + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d97b7a8..fc27b8b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,6 +20,8 @@ jobs: uses: samply/github-workflows/.github/workflows/docker-ci.yml@main with: image-name: "samply/lens-web-components" + build-args: | + TARGET_ENVIRONMENT=production # This passes the secrets from calling workflow to the called workflow secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/Dockerfile b/Dockerfile index 2a47a17..6e2c7c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ FROM node:lts as build +ARG TARGET_ENVIRONMENT="staging" WORKDIR /usr/src/app RUN sh -c '[ -z "$http_proxy" ] || ( npm config set proxy $http_proxy; npm config set https-proxy $http_proxy )' COPY package.json package-lock.json ./ RUN npm install COPY ./vite.config.ts ./vite.demo.config.ts ./extensions.json ./tsconfig.json ./tsconfig.node.json ./ COPY ./packages ./packages -RUN npm run build -RUN npm run build:demo +RUN VITE_TARGET_ENVIRONMENT=${TARGET_ENVIRONMENT} npm run build +RUN VITE_TARGET_ENVIRONMENT=${TARGET_ENVIRONMENT} npm run build:demo FROM nginx:stable-alpine COPY --from=build /usr/src/app/dist/demo /usr/share/nginx/html diff --git a/packages/demo/src/AppCCP.svelte b/packages/demo/src/AppCCP.svelte index 2a74950..80bea1b 100644 --- a/packages/demo/src/AppCCP.svelte +++ b/packages/demo/src/AppCCP.svelte @@ -112,9 +112,13 @@ ["hamburg", "Hamburg"], ]; + // VITE_TARGET_ENVIRONMENT should be set by the ci pipeline + const backendUrl = (import.meta.env.VITE_TARGET_ENVIRONMENT === "production") + ? "https://backend.data.dktk.dkfz.de/prod/" + : "https://backend.demo.lens.samply.de/prod/" + const backendConfig = { - // url: "https://backend.demo.lens.samply.de/prod/", - url: "http://localhost:8080", + url: (import.meta.env.PROD) ? backendUrl : "http://localhost:8080", backends: [ "mannheim", "freiburg", diff --git a/packages/lib/src/classes/spot.ts b/packages/lib/src/classes/spot.ts index 679bae5..30edefa 100644 --- a/packages/lib/src/classes/spot.ts +++ b/packages/lib/src/classes/spot.ts @@ -34,7 +34,7 @@ export class Spot { `${this.url}tasks?sites=${this.sites.toString()}`, { method: 'POST', - credentials: 'include', + credentials: (import.meta.env.PROD) ? "include" : "omit", body: query, signal: controller.signal } @@ -54,7 +54,7 @@ export class Spot { const beamResponses: Response = await fetch( `${this.url}tasks/${this.currentTask}?wait_count=${responseCount + 1}`, { - credentials: 'include', + credentials: (import.meta.env.PROD) ? "include" : "omit", signal: controller.signal } )