]> Untitled Git - lemmy-ui.git/blob - Dockerfile
0a23ea897b00c8fb118cac744d12f5d39ad1d971
[lemmy-ui.git] / Dockerfile
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
4 \r
5 WORKDIR /usr/src/app\r
6 \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
11 \r
12 # Cache deps\r
13 COPY package.json yarn.lock ./\r
14 RUN yarn --production --prefer-offline --pure-lockfile\r
15 \r
16 # Build\r
17 COPY generate_translations.js \\r
18   tsconfig.json \\r
19   webpack.config.js \\r
20   .babelrc \\r
21   ./\r
22 \r
23 COPY lemmy-translations lemmy-translations\r
24 COPY src src\r
25 COPY .git .git\r
26 \r
27 # Set UI version \r
28 RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"\r
29 \r
30 RUN yarn --production --prefer-offline\r
31 RUN yarn build:prod\r
32 \r
33 # Prune the image\r
34 RUN node-prune /usr/src/app/node_modules\r
35 \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
39 \r
40 RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'\r
41 \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
45 \r
46 EXPOSE 1234\r
47 WORKDIR /app\r
48 CMD node dist/js/server.js\r