2023-08-17 10:25:11 +08:00
|
|
|
# base image
|
2024-11-14 20:57:01 +08:00
|
|
|
FROM node:20-alpine3.20 AS base
|
2024-01-19 18:11:47 +08:00
|
|
|
LABEL maintainer="takatost@gmail.com"
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-04-14 09:50:34 +08:00
|
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
|
|
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
|
|
|
|
2024-01-19 20:30:36 +08:00
|
|
|
RUN apk add --no-cache tzdata
|
|
|
|
|
|
|
|
|
2023-08-17 10:25:11 +08:00
|
|
|
# install packages
|
2024-06-24 00:45:33 +08:00
|
|
|
FROM base AS packages
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2023-08-17 10:25:11 +08:00
|
|
|
WORKDIR /app/web
|
|
|
|
|
|
|
|
COPY package.json .
|
|
|
|
COPY yarn.lock .
|
|
|
|
|
2024-04-11 18:14:58 +08:00
|
|
|
# if you located in China, you can use taobao registry to speed up
|
2024-04-14 09:50:34 +08:00
|
|
|
# RUN yarn install --frozen-lockfile --registry https://registry.npmmirror.com/
|
2024-04-11 18:14:58 +08:00
|
|
|
|
2024-04-14 09:50:34 +08:00
|
|
|
RUN yarn install --frozen-lockfile
|
2023-08-17 10:25:11 +08:00
|
|
|
|
|
|
|
# build resources
|
2024-06-24 00:45:33 +08:00
|
|
|
FROM base AS builder
|
2023-08-17 10:25:11 +08:00
|
|
|
WORKDIR /app/web
|
|
|
|
COPY --from=packages /app/web/ .
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN yarn build
|
|
|
|
|
|
|
|
|
|
|
|
# production stage
|
2024-06-24 00:45:33 +08:00
|
|
|
FROM base AS production
|
2023-08-17 10:25:11 +08:00
|
|
|
|
2024-06-24 00:45:33 +08:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV EDITION=SELF_HOSTED
|
|
|
|
ENV DEPLOY_ENV=PRODUCTION
|
|
|
|
ENV CONSOLE_API_URL=http://127.0.0.1:5001
|
|
|
|
ENV APP_API_URL=http://127.0.0.1:5001
|
|
|
|
ENV PORT=3000
|
2024-08-12 19:15:41 +08:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-01-19 20:30:36 +08:00
|
|
|
# set timezone
|
2024-06-24 00:45:33 +08:00
|
|
|
ENV TZ=UTC
|
2024-01-19 20:30:36 +08:00
|
|
|
RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \
|
|
|
|
&& echo ${TZ} > /etc/timezone
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-01-29 18:21:15 +08:00
|
|
|
|
2023-05-15 08:51:32 +08:00
|
|
|
WORKDIR /app/web
|
2023-08-17 13:07:07 +08:00
|
|
|
COPY --from=builder /app/web/public ./public
|
2023-08-17 10:25:11 +08:00
|
|
|
COPY --from=builder /app/web/.next/standalone ./
|
|
|
|
COPY --from=builder /app/web/.next/static ./.next/static
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-01-29 18:21:15 +08:00
|
|
|
COPY docker/pm2.json ./pm2.json
|
2023-08-17 10:25:11 +08:00
|
|
|
COPY docker/entrypoint.sh ./entrypoint.sh
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-10-08 11:12:21 +08:00
|
|
|
|
|
|
|
# global runtime packages
|
|
|
|
RUN yarn global add pm2 \
|
|
|
|
&& yarn cache clean \
|
|
|
|
&& mkdir /.pm2 \
|
|
|
|
&& chown -R 1001:0 /.pm2 /app/web \
|
|
|
|
&& chmod -R g=u /.pm2 /app/web
|
|
|
|
|
|
|
|
|
2023-05-15 08:51:32 +08:00
|
|
|
ARG COMMIT_SHA
|
2024-06-24 00:45:33 +08:00
|
|
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-10-08 11:12:21 +08:00
|
|
|
USER 1001
|
2023-08-17 10:25:11 +08:00
|
|
|
EXPOSE 3000
|
2024-01-18 19:12:40 +08:00
|
|
|
ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]
|