modernize dockerfile

master
lauren n. liberda 2023-04-21 16:57:17 +02:00
parent 4bb9d239dd
commit 7e885720da
No known key found for this signature in database
GPG Key ID: 734C629FD04BD319
1 changed files with 10 additions and 8 deletions

View File

@ -1,20 +1,22 @@
FROM node:16-alpine as builder
FROM node:20-alpine as builder
WORKDIR /app
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY src .
RUN yarn install
RUN yarn build
RUN apk add --no-cache vips-dev alpine-sdk && \
yarn install --frozen-lockfile --ignore-scripts && \
npm rebuild sharp --build-from-source && \
NODE_ENV=production yarn build && \
yarn install --production --frozen-lockfile --ignore-scripts && \
npm rebuild sharp --build-from-source
FROM node:16-alpine as runner
FROM node:20-alpine as runner
WORKDIR /app
# reducing container size by eliminating build-only dependencies
COPY package.json .
ENV NODE_ENV=production
RUN yarn install --prod
RUN apk add --no-cache vips-cpp
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/dist /app/dist
EXPOSE 8009
CMD ["yarn", "start"]