From e2443f4defc1d526404b23bed11136340d35c61b Mon Sep 17 00:00:00 2001 From: GoCo Date: Tue, 22 Jul 2025 16:51:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 10 ++++++++++ docker-compose.yaml | 11 +++++++++++ nginx.conf | 11 +++++++++++ 3 files changed, 32 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2478599 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# 使用 node 构建阶段 +FROM node:18 AS builder +WORKDIR /app +COPY . . +RUN npm install && npm run build + +# 使用 nginx 作为生产环境 +FROM nginx:stable-alpine +COPY --from=builder /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..934945f --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3.8' + +services: + vue-app: + build: + context: . + dockerfile: Dockerfile + ports: + - "55511:80" + container_name: vue3-nginx + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..cbb6356 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +}