Skip to content

Commit

Permalink
fix: minify dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
TAK848 committed Feb 26, 2024
1 parent 3627043 commit 46d8994
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
node_modules
4 changes: 2 additions & 2 deletions .github/workflows/deploy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ jobs:
ENV: ${{ env.ENV }}
IMAGE_NAME: ${{ needs.build-and-push.outputs.ecr_image_name }}
CPU: 256
# MEMORY: 512
MEMORY: 512
# CPU: 512
MEMORY: 1024
# MEMORY: 1024
CPU_ARCHITECTURE: ARM64
API_ENDPOINT: https://api.dev.magi-sche.net
4 changes: 2 additions & 2 deletions .github/workflows/deploy_prd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ jobs:
ENV: ${{ env.ENV }}
IMAGE_NAME: ${{ needs.build-and-push.outputs.ecr_image_name }}
CPU: 256
# MEMORY: 512
MEMORY: 512
# CPU: 512
MEMORY: 1024
# MEMORY: 1024
CPU_ARCHITECTURE: ARM64
API_ENDPOINT: https://api.magi-sche.net
24 changes: 16 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
ARG NODE_VERSION=18-slim
ARG NODE_VERSION=18

# Build phase
FROM node:$NODE_VERSION AS builder
FROM node:$NODE_VERSION-slim AS builder
WORKDIR /app

# Prepare node_modules
COPY ./ ./
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile
COPY package.json pnpm-lock.yaml ./

ENV NODE_ENV=production
RUN pnpm install --frozen-lockfile --production
COPY . .

RUN ./node_modules/next/dist/bin/next build

# Run phase
FROM node:$NODE_VERSION AS runner
FROM gcr.io/distroless/nodejs$NODE_VERSION-debian12:latest AS runner

LABEL org.opencontainers.image.source=https://github.com/xpadev-net/video_host_frontend
LABEL org.opencontainers.image.source=https://github.com/magi-sche-org/frontend
WORKDIR /app

COPY --from=builder /app ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/next.config.js ./next.config.js

# Copy artifacts
CMD ["./start.sh"]
CMD ["./node_modules/next/dist/bin/next", "start", "-p", "3000"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"format": "prettier --write \"src/**/*.{tsx,ts,js,json,css,scss}\"",
"lint": "npm run eslint&&npm run check-types",
"lint:fix": "npm run format&&npm run eslint:fix&&npm run check-types",
"prepare": "husky install"
"prepare": "if [ \"$NODE_ENV\" != \"production\" ]; then husky install; fi"
},
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down

0 comments on commit 46d8994

Please sign in to comment.