From 9638cb5cd50c09eb519f6498194d60eb2678a40f Mon Sep 17 00:00:00 2001 From: calsaviour Date: Thu, 29 Jun 2023 23:23:12 +0800 Subject: [PATCH 1/5] Update Dockerfile Update base to node19 alpine --- frontend/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index ff2bdb6..fe0621a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,5 +1,5 @@ # Install dependencies only when needed -FROM node:14-alpine AS deps +FROM node:19-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 @@ -7,14 +7,14 @@ COPY package.json ./ RUN npm install # Rebuild the source code only when needed -FROM node:14-alpine AS builder +FROM node:19-alpine AS builder WORKDIR /app COPY . . COPY --from=deps /app/node_modules ./node_modules RUN npm run build # Production image, copy all the files and run next -FROM node:14-alpine AS runner +FROM node:19-alpine AS runner WORKDIR /app ENV NODE_ENV production @@ -42,4 +42,4 @@ ENV PORT 3000 ENV NEXT_TELEMETRY_DISABLED 1 CMD ["node_modules/.bin/next", "start"] -# ENTRYPOINT ["npm", "start"] \ No newline at end of file +# ENTRYPOINT ["npm", "start"] From 178a06c12f3586aaefccec673ee3e9b58ca956cd Mon Sep 17 00:00:00 2001 From: Calvin Low Date: Fri, 30 Jun 2023 23:15:34 +0800 Subject: [PATCH 2/5] Add github action to build frontend --- .github/workflows/frontend_ci.yml | 38 +++++++++++++++++++++++++++++++ frontend/Dockerfile | 1 + 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/frontend_ci.yml diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml new file mode 100644 index 0000000..2ed5b3a --- /dev/null +++ b/.github/workflows/frontend_ci.yml @@ -0,0 +1,38 @@ +name: Build and Dockerize + +on: + push: + paths: + - 'frontend/**' # Trigger workflow on changes in the frontend folder + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [19.x] # Define the Node.js versions to build for + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + working-directory: frontend + run: npm ci + + - name: Build frontend + working-directory: frontend + run: npm run build + + - name: Build Docker image + uses: docker/build-push-action@v2 + working-directory: frontend + with: + context: . + push: false diff --git a/frontend/Dockerfile b/frontend/Dockerfile index fe0621a..e4bfca1 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -43,3 +43,4 @@ ENV NEXT_TELEMETRY_DISABLED 1 CMD ["node_modules/.bin/next", "start"] # ENTRYPOINT ["npm", "start"] + From 9942a0cb76c382b8e6a12c44ac99c16fd7d287a5 Mon Sep 17 00:00:00 2001 From: Calvin Low Date: Fri, 30 Jun 2023 23:18:35 +0800 Subject: [PATCH 3/5] Add github action to build frontend --- .github/workflows/frontend_ci.yml | 3 +-- frontend/Dockerfile | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index 2ed5b3a..ffb2d48 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -32,7 +32,6 @@ jobs: - name: Build Docker image uses: docker/build-push-action@v2 - working-directory: frontend with: - context: . + context: frontend/. push: false diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e4bfca1..fe0621a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -43,4 +43,3 @@ ENV NEXT_TELEMETRY_DISABLED 1 CMD ["node_modules/.bin/next", "start"] # ENTRYPOINT ["npm", "start"] - From bdbcd0ad1320fa39ebaa0203360b9fc3c467bc12 Mon Sep 17 00:00:00 2001 From: Calvin Low Date: Fri, 30 Jun 2023 23:26:06 +0800 Subject: [PATCH 4/5] Add github action to build frontend --- frontend/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index fe0621a..e4bfca1 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -43,3 +43,4 @@ ENV NEXT_TELEMETRY_DISABLED 1 CMD ["node_modules/.bin/next", "start"] # ENTRYPOINT ["npm", "start"] + From 7a8400818254aa09881c7555dc705745da312ded Mon Sep 17 00:00:00 2001 From: Calvin Low Date: Fri, 30 Jun 2023 23:28:55 +0800 Subject: [PATCH 5/5] Add github action to build frontend --- .github/workflows/frontend_ci.yml | 10 ++++++++++ frontend/Dockerfile | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index ffb2d48..afbfb2e 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -22,6 +22,16 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Create env file + working-directory: frontend + run: | + touch .env + echo ACCESS_KEY="test" >> .env + echo SECRET_KEY="test" >> .env + echo REGION="test" >> .env + echo TABLE_NAME="" >> .env + cat .env + - name: Install dependencies working-directory: frontend run: npm ci diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e4bfca1..fe0621a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -43,4 +43,3 @@ ENV NEXT_TELEMETRY_DISABLED 1 CMD ["node_modules/.bin/next", "start"] # ENTRYPOINT ["npm", "start"] -