Clean up Dockerfile (#2314)

* Clean up Dockerfile

* Reduce image size

Recommended by @kroese
This commit is contained in:
ubergeek77 2024-01-10 17:50:00 -06:00 committed by GitHub
parent 9aa19d8bbd
commit a0add1e61c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,5 @@
FROM node:20-alpine as builder
# Upgrade to edge to fix sharp/libvips issues
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# Added vips-dev and pkgconfig so that local vips is used instead of prebuilt
# Done for two reasons:
# - libvips binaries are not available for ARM32
@ -38,7 +34,7 @@ COPY .git .git
RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"
RUN yarn --production --prefer-offline --network-timeout 100000
RUN NODE_OPTIONS="--max-old-space-size=8192" yarn build:prod
RUN yarn build:prod
RUN rm -rf ./node_modules/import-sort-parser-typescript
RUN rm -rf ./node_modules/typescript
@ -49,11 +45,7 @@ RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'
FROM node:20-alpine as runner
ENV NODE_ENV=production
# Upgrade to edge to fix sharp/libvips issues
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk update && apk upgrade && apk add curl vips-cpp
RUN apk update && apk add --no-cache curl vips-cpp && rm -rf /var/cache/apk/*
COPY --from=builder /usr/src/app/dist /app/dist
COPY --from=builder /usr/src/app/node_modules /app/node_modules