Skip to content

Commit

Permalink
rework dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Sarmiento committed Sep 24, 2023
1 parent 643317f commit 285432a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
47 changes: 21 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
# ---- Base Node ----
FROM node:18-alpine AS base
FROM node:18-alpine AS dependencies

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci

FROM node:18-alpine AS build

WORKDIR /app
COPY package*.json ./

# ---- Dependencies ----
FROM base AS dependencies
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install

# ---- Build ----
FROM dependencies AS build
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .

RUN npx prisma generate
RUN npm run build

# --- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
# copy app sources
COPY . .
# generate prisma client in node_modules
RUN npm run prisma:generate
# copy build files from build image
COPY --from=build /app/.next ./.next
FROM node:18-alpine AS deploy

WORKDIR /app

ENV NODE_ENV production

COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/prisma ./prisma
COPY --from=build /app/.next ./.next

# Expose the listening port
EXPOSE 3000

CMD ["npm", "start"]

# Install additional tools (curl and grep)
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,md}'",
"prisma:generate": "prisma generate"
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,md}'"
},
"dependencies": {
"@ctrl/video-filename-parser": "^4.12.0",
Expand Down

0 comments on commit 285432a

Please sign in to comment.