]> Untitled Git - lemmy-ui.git/blobdiff - Dockerfile
fix submodule error
[lemmy-ui.git] / Dockerfile
index 745651b54f7728b4054a320b2105d133ad816e23..00baae145182ff8b502fcbd14ae8c49c9e10f1a4 100644 (file)
@@ -1,13 +1,16 @@
-FROM node:14-alpine as builder\r
-RUN apk update && apk add yarn curl bash && rm -rf /var/cache/apk/*\r
-\r
-RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin\r
+FROM node:20.2-alpine as builder\r
+RUN apk update && apk add curl yarn python3 build-base gcc wget git --no-cache\r
+RUN curl -sf https://gobinaries.com/tj/node-prune | sh\r
 \r
 WORKDIR /usr/src/app\r
 \r
+ENV npm_config_target_arch=x64\r
+ENV npm_config_target_platform=linux\r
+ENV npm_config_target_libc=musl\r
+\r
 # Cache deps\r
 COPY package.json yarn.lock ./\r
-RUN yarn install --pure-lockfile\r
+RUN yarn --production --prefer-offline --pure-lockfile\r
 \r
 # Build\r
 COPY generate_translations.js \\r
@@ -18,18 +21,30 @@ COPY generate_translations.js \
 \r
 COPY lemmy-translations lemmy-translations\r
 COPY src src\r
+COPY .git .git\r
+\r
+# Set UI version \r
+RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"\r
 \r
-RUN yarn\r
-RUN yarn build:prod\r
+RUN yarn --production --prefer-offline\r
+RUN NODE_OPTIONS="--max-old-space-size=8192" yarn build:prod\r
 \r
-# Pruning\r
-# RUN npm prune --production\r
-RUN /usr/local/bin/node-prune\r
+# Prune the image\r
+RUN node-prune /usr/src/app/node_modules\r
 \r
-FROM node:14-alpine as runner\r
+RUN rm -rf ./node_modules/import-sort-parser-typescript\r
+RUN rm -rf ./node_modules/typescript\r
+RUN rm -rf ./node_modules/npm\r
+\r
+RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'\r
+\r
+FROM node:alpine as runner\r
 COPY --from=builder /usr/src/app/dist /app/dist\r
 COPY --from=builder /usr/src/app/node_modules /app/node_modules\r
 \r
+RUN chown -R node:node /app\r
+\r
+USER node\r
 EXPOSE 1234\r
 WORKDIR /app\r
 CMD node dist/js/server.js\r