Skip to content

Commit

Permalink
Try faster build
Browse files Browse the repository at this point in the history
  • Loading branch information
wengj9 committed Sep 24, 2024
1 parent abea023 commit b0acf10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
43 changes: 12 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
FROM node:lts AS builder
FROM node:lts-slim AS base

# make workdir /app
WORKDIR /app

# install pnpm
RUN corepack enable && corepack prepare pnpm@v9.10.0 --activate

# Install requested packages
COPY pnpm-lock.yaml ./
RUN pnpm fetch

# Copy app source and install dependencies
COPY . .
RUN pnpm install -r --offline --ignore-scripts
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# transpile to js
RUN pnpm build
FROM base AS prod

FROM node:lts-alpine AS final

# make workdir /app
COPY pnpm-lock.yaml /app
WORKDIR /app

# install pnpm
RUN corepack enable && corepack prepare pnpm@v9.10.0 --activate

# Fetch production packages
COPY pnpm-lock.yaml ./
RUN pnpm fetch --prod

# copy transpiled code, install prod dependencies
COPY --from=builder ./app/dist ./dist
COPY package.json .
RUN pnpm install -r --offline --prod --ignore-scripts
COPY . /app
RUN pnpm run build

# start server
CMD cd dist && node deploy-commands.js && node .
FROM base
COPY --from=prod /app/node_modules /app/node_modules
COPY --from=prod /app/dist /app/dist
CMD [ "pnpm", "start" ]
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"type": "module",
"scripts": {
"build": "tsc",
"deploy-cmd": "tsc && cd dist && node deploy-commands.js",
"start": "tsc && cd dist && node .",
"start": "cd dist && node deploy-commands.js && node .",
"prettify": "prettier --write . --plugin-search-dir=. --ignore-unknown",
"pm2": "pm2 start \"pnpm start\"",
"lint": "eslint --cache . --fix",
Expand Down

0 comments on commit b0acf10

Please sign in to comment.