-FROM node:14\r
-WORKDIR /usr/src/app_name\r
-COPY . .\r
+FROM node:alpine as builder\r
+RUN apk update && apk add yarn python3 build-base gcc wget git --no-cache\r
+\r
+WORKDIR /usr/src/app\r
+\r
+# Cache deps\r
+COPY package.json yarn.lock ./\r
+RUN yarn install --pure-lockfile\r
+\r
+# Build\r
+COPY generate_translations.js \\r
+ tsconfig.json \\r
+ webpack.config.js \\r
+ .babelrc \\r
+ ./\r
+\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:server\r
-RUN yarn build:client\r
+RUN yarn build:prod\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
EXPOSE 1234\r
-CMD yarn serve\r
+WORKDIR /app\r
+CMD node dist/js/server.js\r