From 65d3e64f4aa8053c683541c67b16d0c61ac2a64a Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:29:59 +0100 Subject: [PATCH 1/7] Fixing docker file --- .github/workflows/pushImage.yml | 23 ++++++++++++----------- Dockerfile | 12 +----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pushImage.yml b/.github/workflows/pushImage.yml index 2ce7fdb..949f830 100644 --- a/.github/workflows/pushImage.yml +++ b/.github/workflows/pushImage.yml @@ -6,6 +6,7 @@ on: branches: - release/** - develop + - fix-docker-image-yarn-issue paths-ignore: - '*.md' @@ -51,7 +52,7 @@ jobs: runs-on: ubuntu-latest outputs: - docker-image-name: ${{ steps.docker-image-name.outputs.name }} + docker-image-name: ${{ steps.docker-image-name.outputs.name }} steps: - uses: actions/checkout@v3 @@ -78,26 +79,26 @@ jobs: - name: Build Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: docker build -t $ECR_REGISTRY/find-a-grant-api:${{ env.BUILD_VERSION }} . - name: Generate Docker image name id: docker-image-name run: | - NAME=${{ (github.ref == 'refs/heads/develop' && 'find-api-dev-image') || (startsWith(github.ref, 'refs/heads/release') && 'find-api-qa-image') }} - echo "name=$NAME" >> $GITHUB_OUTPUT - + NAME=${{ (github.ref == 'refs/heads/develop' && 'find-api-dev-image') || (startsWith(github.ref, 'refs/heads/release') && 'find-api-qa-image') }} + echo "name=$NAME" >> $GITHUB_OUTPUT + - name: Save Docker image env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: docker save --output ${{ steps.docker-image-name.outputs.name }}.tar $ECR_REGISTRY/find-a-grant-api:${{ env.BUILD_VERSION }} - + - name: Upload Docker image uses: actions/upload-artifact@v3 with: - name: ${{ steps.docker-image-name.outputs.name }} - path: ${{ steps.docker-image-name.outputs.name }}.tar - retention-days: 1 + name: ${{ steps.docker-image-name.outputs.name }} + path: ${{ steps.docker-image-name.outputs.name }}.tar + retention-days: 1 deploy: runs-on: ubuntu-latest @@ -130,7 +131,7 @@ jobs: - name: Download Docker image uses: actions/download-artifact@v3 with: - name: ${{ needs.build.outputs.docker-image-name }} + name: ${{ needs.build.outputs.docker-image-name }} - name: Load Docker image run: docker load --input ${{ needs.build.outputs.docker-image-name }}.tar diff --git a/Dockerfile b/Dockerfile index e73fc4f..a70e098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,24 +4,15 @@ FROM node:16-alpine AS deps RUN apk add --no-cache libc6-compat WORKDIR /app - -RUN echo -e "\nnodeLinker: node-modules" >> .yarnrc.yml - # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ RUN \ - if [ -f yarn.lock ]; then yarn set version berry && yarn --immutable; \ + if [ -f yarn.lock ]; then yarn --immutable; \ elif [ -f package-lock.json ]; then npm ci; \ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ else echo "Lockfile not found." && exit 1; \ fi -#temp debug -RUN yarn -v -RUN ls -a -RUN ls -a /app/ -RUN cat .yarnrc.yml - # Rebuild the source code only when needed FROM node:16-alpine AS builder WORKDIR /app @@ -30,7 +21,6 @@ COPY . . RUN yarn build - FROM node:16-alpine AS runner WORKDIR /app From ede368b2a931dadd636024e3da38c640a67017f9 Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:36:52 +0100 Subject: [PATCH 2/7] Attempt #2 electric boogaloo --- Dockerfile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index a70e098..e88e550 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /app # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ RUN \ - if [ -f yarn.lock ]; then yarn --immutable; \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ else echo "Lockfile not found." && exit 1; \ @@ -26,15 +26,6 @@ WORKDIR /app ENV NODE_ENV production -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --immutable; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - # Copy production build COPY --from=builder /app/dist/ ./dist/ From 1de2909a077e577c3fbe802487c4fc6583ec0cc8 Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:43:01 +0100 Subject: [PATCH 3/7] Fix #3 lets gooo --- Dockerfile | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index e88e550..d65db64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,13 @@ FROM node:16-alpine AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat -WORKDIR /app -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Rebuild the source code only when needed -FROM node:16-alpine AS builder WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . + +COPY package.json . +COPY yarn.lock . + +RUN yarn install --immutable RUN yarn build From d8ba15e2e79588e9f301328d3d6ded397960fdbd Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:45:55 +0100 Subject: [PATCH 4/7] #5... --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d65db64..8bb724e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ -# Install dependencies only when needed -FROM node:16-alpine AS deps +FROM node:16-alpine AS build # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat -WORKDIR /app +WORKDIR /usr/src/app COPY package.json . COPY yarn.lock . @@ -18,7 +17,7 @@ WORKDIR /app ENV NODE_ENV production # Copy production build -COPY --from=builder /app/dist/ ./dist/ +COPY --from=build /app/dist/ ./dist/ # Expose application port EXPOSE 3000 From 93555cbeacb3dcf2a9c5c2789b30474d54dd9da4 Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:49:12 +0100 Subject: [PATCH 5/7] Mb now its #5, fixing directory path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8bb724e..5c6346e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:16-alpine AS build # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat -WORKDIR /usr/src/app +WORKDIR /app COPY package.json . COPY yarn.lock . From 4caaa8be884c94761d0e1c08575ba2270ae7ca81 Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:52:54 +0100 Subject: [PATCH 6/7] #6 copying over tsconfig files --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5c6346e..89e44f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ WORKDIR /app COPY package.json . COPY yarn.lock . +COPY tsconfig.build.json . +COPY tsconfig.json . RUN yarn install --immutable From a648740b8f354e3c9763f4d2a859d15cd04dc5af Mon Sep 17 00:00:00 2001 From: dominicwest Date: Tue, 24 Oct 2023 16:59:45 +0100 Subject: [PATCH 7/7] Removing test branch trigger --- .github/workflows/pushImage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pushImage.yml b/.github/workflows/pushImage.yml index 949f830..10cbda1 100644 --- a/.github/workflows/pushImage.yml +++ b/.github/workflows/pushImage.yml @@ -6,7 +6,6 @@ on: branches: - release/** - develop - - fix-docker-image-yarn-issue paths-ignore: - '*.md'