diff --git a/.github/workflows/image-push-stage.yml b/.github/workflows/image-push-stage.yml index 1796e6c2e..5807707fc 100644 --- a/.github/workflows/image-push-stage.yml +++ b/.github/workflows/image-push-stage.yml @@ -17,10 +17,24 @@ jobs: include: - dockerfile: admin.k8s.Dockerfile image_name: nutfes/group-manager-2-admin-view + vue_app_url: '' + vue_app_api_url: '' + imgur_id: '' + imgur_token: '' + - dockerfile: front.k8s.Dockerfile image_name: nutfes/group-manager-2-user-front + vue_app_url: ${{ secrets.VUE_APP_URL }} + vue_app_api_url: ${{ secrets.VUE_APP_API_URL }} + imgur_id: ${{ secrets.NUXT_IMGUR_CLIENT_ID }} + imgur_token: ${{ secrets.NUXT_IMGUR_CLIENT_SECRET }} + - dockerfile: api.k8s.Dockerfile image_name: nutfes/group-manager-2-api + vue_app_url: ${{ secrets.VUE_APP_URL }} + vue_app_api_url: ${{ secrets.VUE_APP_API_URL }} + imgur_id: '' + imgur_token: '' steps: @@ -43,4 +57,9 @@ jobs: file: ${{ matrix.dockerfile }} push: true tags: ${{ matrix.image_name }}:latest + build-args: | + VUE_APP_URL=${{ matrix.vue_app_url }} + VUE_APP_API_URL=${{ matrix.vue_app_api_url }} + NUXT_IMGUR_CLIENT_ID=${{ matrix.imgur_id }} + NUXT_IMGUR_CLIENT_SECRET=${{ matrix.imgur_token }} diff --git a/admin.k8s.Dockerfile b/admin.k8s.Dockerfile index dce4458a4..10bdd9f06 100644 --- a/admin.k8s.Dockerfile +++ b/admin.k8s.Dockerfile @@ -2,6 +2,14 @@ FROM node:16-bookworm-slim AS builder WORKDIR /app +# Accept API URL as a build-time environment variable +ARG API_URL +ARG APP_API_URL + +# Set the environment variable +ENV VUE_APP_URL=${API_URL} +ENV VUE_APP_API_URL=${APP_API_URL} + # Copy package.json and package-lock.json (or npm-shrinkwrap.json) COPY ./admin_view/nuxt-project/package*.json ./ diff --git a/front.k8s.Dockerfile b/front.k8s.Dockerfile index 1b8b4d338..810c730b8 100644 --- a/front.k8s.Dockerfile +++ b/front.k8s.Dockerfile @@ -2,13 +2,23 @@ FROM node:18-bookworm-slim AS builder WORKDIR /app +# Accept API URL as a build-time environment variable +ARG API_URL +ARG APP_API_URL +ARG IMGUR_ID +ARG IMGUR_SECRET + +# Set the environment variable +ENV VUE_APP_URL=${API_URL} +ENV VUE_APP_API_URL=${APP_API_URL} +ENV NUXT_IMGUR_CLIENT_ID=${IMGUR_ID} +ENV NUXT_IMGUR_CLIENT_SECRET=${IMGUR_SECRET} + # Install postinstall necessary for Nuxt 3 COPY ./user_front/package*.json ./ RUN npm ci - # Copy the rest of your Vue.js application source code COPY ./user_front/ ./ - # Build the application RUN npm run build @@ -18,11 +28,9 @@ WORKDIR /app # Copy the built server and client code COPY --from=builder /app/.output ./output - # Set environment variables ENV NODE_ENV production - # Expose the port the app runs on EXPOSE 3000