添加dockerfile
This commit is contained in:
14
.dockerignore
Normal file
14
.dockerignore
Normal file
@@ -0,0 +1,14 @@
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
node_modules
|
||||
**/node_modules
|
||||
dist
|
||||
**/dist
|
||||
.taro
|
||||
**/.taro
|
||||
coverage
|
||||
*.log
|
||||
.DS_Store
|
||||
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@@ -0,0 +1,53 @@
|
||||
FROM node:22-bookworm-slim AS dependencies
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
COPY apps/api/package.json apps/api/package.json
|
||||
COPY apps/admin/package.json apps/admin/package.json
|
||||
COPY apps/miniprogram/package.json apps/miniprogram/package.json
|
||||
RUN npm ci
|
||||
|
||||
FROM dependencies AS api-builder
|
||||
|
||||
COPY apps/api apps/api
|
||||
RUN npm run build:api \
|
||||
&& npm prune --omit=dev
|
||||
|
||||
FROM node:22-bookworm-slim AS api
|
||||
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=api-builder /app/package.json /app/package-lock.json ./
|
||||
COPY --from=api-builder /app/node_modules ./node_modules
|
||||
COPY --from=api-builder /app/apps/api/package.json ./apps/api/package.json
|
||||
COPY --from=api-builder /app/apps/api/node_modules ./apps/api/node_modules
|
||||
COPY --from=api-builder /app/apps/api/dist ./apps/api/dist
|
||||
COPY --from=api-builder /app/apps/api/prisma ./apps/api/prisma
|
||||
|
||||
USER node
|
||||
EXPOSE 4000
|
||||
|
||||
CMD ["node", "apps/api/dist/index.js"]
|
||||
|
||||
FROM dependencies AS admin-builder
|
||||
|
||||
ARG VITE_API_BASE_URL=http://localhost:4000
|
||||
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
|
||||
|
||||
COPY apps/admin apps/admin
|
||||
RUN npm run build:admin
|
||||
|
||||
FROM nginx:1.28-alpine AS admin
|
||||
|
||||
COPY docker/admin.nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=admin-builder /app/apps/admin/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
FROM api AS runtime
|
||||
11
docker/admin.nginx.conf
Normal file
11
docker/admin.nginx.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user