From 6d36b2f28a6f5b312a8f25d4496dd7dfa729543e Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Thu, 17 Oct 2024 17:51:15 -0700 Subject: [PATCH 1/2] change path to COPY staging/* ./dist/wfprev in ui dockerfile --- client/wfprev-war/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/wfprev-war/Dockerfile b/client/wfprev-war/Dockerfile index 54d8c53d..6645d1e9 100644 --- a/client/wfprev-war/Dockerfile +++ b/client/wfprev-war/Dockerfile @@ -5,7 +5,7 @@ FROM node:20-alpine WORKDIR /app # Copy the pre-built Angular app from the local machine into the container -COPY src/main/angular/dist/wfprev ./dist/wfprev +COPY staging/* ./dist/wfprev # Copy backend files (for serving the Angular app using Express) COPY backend /app From 779e3804b37f033f36645c6d3febb5c743c2ed0a Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Thu, 17 Oct 2024 21:28:08 -0700 Subject: [PATCH 2/2] dockerfile update --- .github/workflows/mvn-build.yml | 43 +++++++++++++++++++++++++++------ client/wfprev-war/Dockerfile | 2 +- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mvn-build.yml b/.github/workflows/mvn-build.yml index 3efe28ee..ca437c35 100644 --- a/.github/workflows/mvn-build.yml +++ b/.github/workflows/mvn-build.yml @@ -72,6 +72,7 @@ jobs: run: | cd ${{ inputs.COMPONENT_TYPE }}/wfprev-war/src/main/angular npm install + - name: Build Angular app if: ${{ inputs.COMPONENT_TYPE == 'client' }} run: | @@ -81,6 +82,13 @@ jobs: - name: Copy built files to necessary folders if: ${{ inputs.COMPONENT_TYPE == 'client' }} run: mkdir -p staging && cp -r ${{ inputs.COMPONENT_TYPE }}/wfprev-war/src/main/angular/dist/wfprev/* staging/ + + - name: Upload Angular build artifact + if: ${{ inputs.COMPONENT_TYPE == 'client' }} + uses: actions/upload-artifact@v3 + with: + name: angular-build + path: staging - name: Build API with Maven if: ${{ inputs.COMPONENT_TYPE == 'server' }} @@ -129,6 +137,15 @@ jobs: # with: # ref: ${{ inputs.BRANCH }} + # Download Angular build artifact + - name: Download Angular build artifact + if: ${{ inputs.COMPONENT_TYPE == 'client' }} + uses: actions/download-artifact@v3 + with: + name: angular-build + path: staging + + - name: download artifact uses: actions/download-artifact@v3 with: @@ -164,12 +181,24 @@ jobs: type=ref,event=tag type=raw,value=${{ inputs.TAG }} - - name: Build and push Docker image + - name: Build and push Docker image for Client (UI) + if: ${{ inputs.COMPONENT_TYPE == 'client' }} + uses: docker/build-push-action@v6 + with: + context: . # Root context to include the staging folder for client builds + build-args: | + CONTAINER_NAME=${{inputs.COMPONENT_NAME}} + push: true + tags: ${{ steps.meta_pr.outputs.tags }} + labels: ${{ steps.meta_pr.outputs.labels }} + + - name: Build and push Docker image for Server (API) + if: ${{ inputs.COMPONENT_TYPE == 'server' }} uses: docker/build-push-action@v6 with: - context: ${{inputs.COMPONENT_TYPE}}/${{inputs.COMPONENT_NAME}} - build-args: | - CONTAINER_NAME=${{inputs.COMPONENT_NAME}} - push: true - tags: ${{ steps.meta_pr.outputs.tags }} - labels: ${{ steps.meta_pr.outputs.labels }} + context: ${{ inputs.COMPONENT_TYPE }}/wfprev-api + build-args: | + CONTAINER_NAME=${{inputs.COMPONENT_NAME}} + push: true + tags: ${{ steps.meta_pr.outputs.tags }} + labels: ${{ steps.meta_pr.outputs.labels }} \ No newline at end of file diff --git a/client/wfprev-war/Dockerfile b/client/wfprev-war/Dockerfile index 6645d1e9..f6336ec0 100644 --- a/client/wfprev-war/Dockerfile +++ b/client/wfprev-war/Dockerfile @@ -5,7 +5,7 @@ FROM node:20-alpine WORKDIR /app # Copy the pre-built Angular app from the local machine into the container -COPY staging/* ./dist/wfprev +COPY ./staging/* ./dist/wfprev # Copy backend files (for serving the Angular app using Express) COPY backend /app