diff --git a/Dockerfile b/Dockerfile index e00724c..1bdcf23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,23 @@ -FROM node:18-alpine As dev +FROM node:20-alpine As builder RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories RUN apk update && apk add sqlite RUN apk add --no-cache --virtual .build-deps g++ gcc libgcc libstdc++ linux-headers make python3 WORKDIR /app COPY package*.json . -RUN npm install +COPY .npmrc . +RUN corepack enable +RUN pnpm install COPY . . -RUN npm run build && npm prune --production +RUN pnpm build && pnpm prune --prod -FROM node:18-alpine As build +FROM node:20-alpine WORKDIR /app ENV NODE_ENV production -COPY --from=dev /app/content/ ./content/ -COPY --from=dev /app/dist/ ./dist/ -COPY --from=dev /app/node_modules/ ./node_modules/ -COPY --from=dev /app/.env ./ -COPY --from=dev /app/package.json ./ +COPY --from=builder /app/content/ ./content/ +COPY --from=builder /app/dist/ ./dist/ +COPY --from=builder /app/node_modules/ ./node_modules/ +COPY --from=builder /app/.env ./ +COPY --from=builder /app/package.json ./ EXPOSE 3030 CMD [ "node", "./dist/main.js" ]