-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e7d750
commit db51be6
Showing
2 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
FROM node:20-alpine as builder | ||
|
||
# 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 | ||
# - It can break depending on the CPU (https://github.com/LemmyNet/lemmy-ui/issues/1566) | ||
RUN apk update && apk upgrade && apk add --no-cache curl yarn python3 build-base gcc wget git vips-dev pkgconfig | ||
|
||
# Install node-gyp | ||
RUN npm install -g node-gyp | ||
|
||
WORKDIR /usr/src/app | ||
|
||
ENV npm_config_target_platform=linux | ||
ENV npm_config_target_libc=musl | ||
|
||
# Cache deps | ||
COPY package.json yarn.lock ./ | ||
|
||
RUN yarn --production --prefer-offline --pure-lockfile --network-timeout 100000 | ||
|
||
# Build | ||
COPY generate_translations.js \ | ||
tsconfig.json \ | ||
webpack.config.js \ | ||
.babelrc \ | ||
./ | ||
|
||
COPY lemmy-translations lemmy-translations | ||
COPY src src | ||
COPY .git .git | ||
|
||
# Set UI version | ||
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 rm -rf ./node_modules/import-sort-parser-typescript | ||
RUN rm -rf ./node_modules/typescript | ||
RUN rm -rf ./node_modules/npm | ||
|
||
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 | ||
|
||
COPY --from=builder /usr/src/app/dist /app/dist | ||
COPY --from=builder /usr/src/app/node_modules /app/node_modules | ||
|
||
RUN chown -R node:node /app | ||
|
||
HEALTHCHECK --interval=60s --start-period=10s --retries=2 --timeout=10s CMD curl -ILfSs http://localhost:1234/ > /dev/null || exit 1 | ||
|
||
USER node | ||
EXPOSE 1234 | ||
WORKDIR /app | ||
CMD exec node dist/js/server.js |