Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Update Dockerfile #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/frontend_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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: 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

- name: Build frontend
working-directory: frontend
run: npm run build

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: frontend/.
push: false
8 changes: 4 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# 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
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
Expand Down Expand Up @@ -42,4 +42,4 @@ ENV PORT 3000
ENV NEXT_TELEMETRY_DISABLED 1

CMD ["node_modules/.bin/next", "start"]
# ENTRYPOINT ["npm", "start"]
# ENTRYPOINT ["npm", "start"]