-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
33 lines (21 loc) · 1.01 KB
/
Copy pathDockerfile.frontend
File metadata and controls
33 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FROM node:22-bookworm-slim
ARG NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1
ARG INTERNAL_API_URL=http://backend:8000/api/v1
ARG FRONTEND_MODE=production
RUN apt-get update && apt-get install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=${FRONTEND_MODE} \
FRONTEND_MODE=${FRONTEND_MODE} \
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} \
INTERNAL_API_URL=${INTERNAL_API_URL} \
TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
WORKDIR /app/frontend
RUN corepack enable
COPY frontend/package.json frontend/pnpm-lock.yaml /app/frontend/
RUN pnpm install --frozen-lockfile
COPY frontend/ /app/frontend/
RUN if [ "${FRONTEND_MODE}" = "production" ]; then \
pnpm build && pnpm prune --prod; \
fi
EXPOSE 3000
CMD ["sh", "-lc", "if [ \"$FRONTEND_MODE\" = \"development\" ]; then pnpm install --frozen-lockfile && exec pnpm dev --hostname 0.0.0.0 --port 3000; else exec pnpm start --hostname 0.0.0.0 --port 3000; fi"]