|
|
|
FROM node:20.11-alpine3.19 AS base |
|
LABEL maintainer="takatost@gmail.com" |
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache tzdata |
|
|
|
|
|
|
|
FROM base AS packages |
|
|
|
WORKDIR /app/web |
|
|
|
COPY package.json . |
|
COPY yarn.lock . |
|
|
|
|
|
|
|
|
|
RUN yarn install --frozen-lockfile |
|
|
|
|
|
FROM base AS builder |
|
WORKDIR /app/web |
|
COPY --from=packages /app/web/ . |
|
COPY . . |
|
|
|
RUN yarn build |
|
|
|
|
|
|
|
FROM base AS production |
|
|
|
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 |
|
ENV NEXT_TELEMETRY_DISABLED=1 |
|
|
|
|
|
ENV TZ=UTC |
|
RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \ |
|
&& echo ${TZ} > /etc/timezone |
|
|
|
|
|
WORKDIR /app/web |
|
COPY --from=builder /app/web/public ./public |
|
COPY --from=builder /app/web/.next/standalone ./ |
|
COPY --from=builder /app/web/.next/static ./.next/static |
|
|
|
COPY docker/pm2.json ./pm2.json |
|
COPY docker/entrypoint.sh ./entrypoint.sh |
|
|
|
|
|
|
|
RUN yarn global add pm2 \ |
|
&& yarn cache clean \ |
|
&& mkdir /.pm2 \ |
|
&& chown -R 1001:0 /.pm2 /app/web \ |
|
&& chmod -R g=u /.pm2 /app/web |
|
|
|
|
|
ARG COMMIT_SHA |
|
ENV COMMIT_SHA=${COMMIT_SHA} |
|
|
|
USER 1001 |
|
EXPOSE 3000 |
|
ENTRYPOINT ["/bin/sh", "./entrypoint.sh"] |
|
|