From a1084ee5edc6035583431f814575f2cb8c8465b6 Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Mon, 4 Mar 2024 10:20:16 +0800 Subject: [PATCH] test: test build --- Dockerfile | 12 ++++++------ docker-compose.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c670f9..33c4815 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ +FROM nginx:alpine as production +EXPOSE 80 + FROM node:20-slim as base ENV PROJECT_DIR=/huaxin-front \ PNPM_HOME="/pnpm" \ @@ -25,10 +28,7 @@ RUN pnpm run build FROM base AS result 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/ /usr/share/nginx/html +COPY --from=builder $PROJECT_DIR/nginx.conf /etc/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 \ No newline at end of file + diff --git a/docker-compose.yml b/docker-compose.yml index 1f8774c..fa5d10d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: build: context: . dockerfile: Dockerfile - target: production + target: result container_name: huaxin-base-frontend ports: - '80:80'