2024-01-11 00:14:18 +00:00
|
|
|
FROM node:21-alpine as builder
|
2023-11-27 12:32:04 +00:00
|
|
|
|
|
|
|
# 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)
|
2024-01-29 03:09:08 +00:00
|
|
|
RUN apk update && apk upgrade && apk add --no-cache curl python3 build-base gcc wget git vips-dev pkgconfig
|
2023-11-27 12:32:04 +00:00
|
|
|
|
2024-01-29 03:09:08 +00:00
|
|
|
# Install node-gyp and pnpm
|
|
|
|
RUN npm install -g pnpm node-gyp
|
2020-09-09 23:56:02 +00:00
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
2023-05-12 01:07:59 +00:00
|
|
|
ENV npm_config_target_platform=linux
|
|
|
|
ENV npm_config_target_libc=musl
|
|
|
|
|
2020-09-09 23:56:02 +00:00
|
|
|
# Cache deps
|
2024-01-29 03:09:08 +00:00
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
RUN pnpm i
|
2020-10-23 12:14:42 +00:00
|
|
|
# Build
|
2020-09-09 23:56:02 +00:00
|
|
|
COPY generate_translations.js \
|
|
|
|
tsconfig.json \
|
|
|
|
webpack.config.js \
|
|
|
|
.babelrc \
|
2020-10-23 12:14:42 +00:00
|
|
|
./
|
|
|
|
|
2020-09-10 19:49:33 +00:00
|
|
|
COPY lemmy-translations lemmy-translations
|
2020-09-09 23:56:02 +00:00
|
|
|
COPY src src
|
2021-04-26 13:57:41 +00:00
|
|
|
COPY .git .git
|
|
|
|
|
|
|
|
# Set UI version
|
|
|
|
RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"
|
2024-01-22 14:06:45 +00:00
|
|
|
RUN echo "export const BUILD_DATE_ISO8601 = '$(date -u +"%Y-%m-%dT%H:%M:%SZ")';" > "src/shared/build-date.ts"
|
2020-09-09 23:56:02 +00:00
|
|
|
|
2024-01-29 03:09:08 +00:00
|
|
|
RUN pnpm i
|
|
|
|
RUN pnpm prebuild:prod
|
|
|
|
RUN pnpm build:prod
|
2020-09-09 23:56:02 +00:00
|
|
|
|
2022-10-21 19:28:18 +00:00
|
|
|
RUN rm -rf ./node_modules/import-sort-parser-typescript
|
|
|
|
RUN rm -rf ./node_modules/typescript
|
|
|
|
RUN rm -rf ./node_modules/npm
|
|
|
|
|
2024-01-11 00:14:18 +00:00
|
|
|
FROM node:21-alpine as runner
|
2023-11-27 12:32:04 +00:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
2024-01-10 23:50:00 +00:00
|
|
|
RUN apk update && apk add --no-cache curl vips-cpp && rm -rf /var/cache/apk/*
|
2023-11-27 12:32:04 +00:00
|
|
|
|
2020-09-09 23:56:02 +00:00
|
|
|
COPY --from=builder /usr/src/app/dist /app/dist
|
|
|
|
COPY --from=builder /usr/src/app/node_modules /app/node_modules
|
|
|
|
|
2023-07-10 14:50:25 +00:00
|
|
|
RUN chown -R node:node /app
|
|
|
|
|
2023-11-27 12:32:04 +00:00
|
|
|
LABEL org.opencontainers.image.authors="The Lemmy Authors"
|
|
|
|
LABEL org.opencontainers.image.source="https://github.com/LemmyNet/lemmy-ui"
|
|
|
|
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
|
|
|
LABEL org.opencontainers.image.description="The official web app for Lemmy."
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=60s --start-period=10s --retries=2 --timeout=10s CMD curl -ILfSs http://localhost:1234/ > /dev/null || exit 1
|
|
|
|
|
2023-07-10 14:50:25 +00:00
|
|
|
USER node
|
2020-09-07 03:41:46 +00:00
|
|
|
EXPOSE 1234
|
2020-09-10 16:39:01 +00:00
|
|
|
WORKDIR /app
|
2024-01-11 00:14:18 +00:00
|
|
|
|
|
|
|
CMD ["node", "dist/js/server.js"]
|