test: test build

This commit is contained in:
louis 2024-03-04 10:20:16 +08:00
parent 18b0fefce8
commit a1084ee5ed
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,7 @@
FROM nginx:alpine as production
EXPOSE 80
FROM node:20-slim as base FROM node:20-slim as base
ENV PROJECT_DIR=/huaxin-front \ ENV PROJECT_DIR=/huaxin-front \
PNPM_HOME="/pnpm" \ PNPM_HOME="/pnpm" \
@ -25,10 +28,7 @@ RUN pnpm run build
FROM base AS result FROM base AS result
COPY --from=prod-deps $PROJECT_DIR/node_modules $PROJECT_DIR/node_modules COPY --from=prod-deps $PROJECT_DIR/node_modules $PROJECT_DIR/node_modules
COPY --from=builder $PROJECT_DIR/dist $PROJECT_DIR/dist COPY --from=builder $PROJECT_DIR/dist $PROJECT_DIR/dist
COPY --from=builder $PROJECT_DIR/dist/ /usr/share/nginx/html
COPY --from=builder $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf
# 构建nginx,并且在result之后拷贝dist到nginx中其中包含了自定义nginx.conf # 构建nginx,并且在result之后拷贝dist到nginx中其中包含了自定义nginx.conf
FROM nginx:alpine as production
ENV PROJECT_DIR=/huaxin-front
COPY --from=result $PROJECT_DIR/dist/ /usr/share/nginx/html
COPY --from=result $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

View File

@ -6,7 +6,7 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
target: production target: result
container_name: huaxin-base-frontend container_name: huaxin-base-frontend
ports: ports:
- '80:80' - '80:80'