-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathDockerfile.web
More file actions
37 lines (34 loc) · 1.33 KB
/
Dockerfile.web
File metadata and controls
37 lines (34 loc) · 1.33 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
34
35
36
37
ARG NODE_IMAGE=node:20-bookworm-slim
ARG NGINX_IMAGE=nginxinc/nginx-unprivileged:1.27-alpine
FROM ${NODE_IMAGE} AS base
ENV PNPM_HOME=/pnpm
ENV PATH=${PNPM_HOME}:${PATH}
ENV NODE_ENV=development
USER root
RUN corepack enable
FROM base AS deps
WORKDIR /app
RUN rm -rf /app/* /app/.[!.]* /app/..?* || true
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.base.json .npmrc ./
COPY client/package.json ./client/package.json
COPY shared/package.json ./shared/package.json
RUN pnpm install --frozen-lockfile --filter @ai-novel/shared --filter @ai-novel/client
FROM deps AS build
WORKDIR /app
ARG VITE_API_BASE_URL=
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
COPY shared/package.json shared/tsconfig.json ./shared/
COPY shared/*.ts ./shared/
COPY shared/types ./shared/types
COPY client/package.json client/tsconfig.json client/vite.config.ts client/tailwind.config.ts client/postcss.config.js client/components.json client/index.html ./client/
COPY client/public ./client/public
COPY client/src ./client/src
RUN pnpm --filter @ai-novel/shared build \
&& pnpm --filter @ai-novel/client build
FROM ${NGINX_IMAGE} AS runtime
USER root
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build --chown=101:101 /app/client/dist/ /usr/share/nginx/html/
COPY --chown=101:101 infra/nginx/ai-novel-web.conf /etc/nginx/conf.d/default.conf
USER 101
EXPOSE 8080