feat: add docker

This commit is contained in:
AnsonCar 2024-11-23 20:20:55 +08:00
parent dd66ec8e20
commit 542df18723
3 changed files with 39 additions and 0 deletions

8
.dockerignore Normal file

@ -0,0 +1,8 @@
/node_modules
/.git
/.gitignore
/.vscode
/.DS_Store
/*.md
/dist

@ -0,0 +1,8 @@
services:
nove-admin:
build:
context: .
dockerfile: ./docker/dockerfile.product
container_name: nove-admin
ports:
- 80:80

23
docker/dockerfile.product Normal file

@ -0,0 +1,23 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS builder
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
FROM nginx:1.23.1-alpine
WORKDIR /www
COPY --from=builder /app/dist/ .
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80