1 FROM node:alpine as builder
\r
2 RUN apk update && apk add curl yarn python3 build-base gcc wget git --no-cache
\r
3 RUN curl -sf https://gobinaries.com/tj/node-prune | sh
\r
7 ENV npm_config_target_arch=x64
\r
8 ENV npm_config_target_platform=linux
\r
9 ENV npm_config_target_libc=musl
\r
10 ENV NODE_ENV=production
\r
13 COPY package.json yarn.lock ./
\r
14 RUN yarn --production --prefer-offline --pure-lockfile
\r
17 COPY generate_translations.js \
\r
23 COPY lemmy-translations lemmy-translations
\r
28 RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"
\r
30 RUN yarn --production --prefer-offline
\r
34 RUN node-prune /usr/src/app/node_modules
\r
36 RUN rm -rf ./node_modules/import-sort-parser-typescript
\r
37 RUN rm -rf ./node_modules/typescript
\r
38 RUN rm -rf ./node_modules/npm
\r
40 RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'
\r
42 FROM node:alpine as runner
\r
43 COPY --from=builder /usr/src/app/dist /app/dist
\r
44 COPY --from=builder /usr/src/app/node_modules /app/node_modules
\r
48 CMD node dist/js/server.js
\r