build: 配置 docker

This commit is contained in:
2026-05-23 12:50:44 +08:00
parent 62a905b17b
commit a577e9eefd
4 changed files with 61 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
node_modules
frontend/node_modules
frontend/dist
backend/bin
.git
+18
View File
@@ -0,0 +1,18 @@
# ---- Build Stage ----
FROM golang:1.26-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/gen2d ./cmd/main.go
# ---- Runtime Stage ----
FROM alpine:3.20
RUN apk add --no-cache ca-certificates
COPY --from=builder /bin/gen2d /usr/local/bin/gen2d
EXPOSE 8080
CMD ["gen2d"]
+21
View File
@@ -0,0 +1,21 @@
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
environment:
- GEN2D_MODE=release
- GEN2D_PORT=8080
expose:
- "8080"
restart: unless-stopped
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "10000:80"
depends_on:
- backend
restart: unless-stopped
+17
View File
@@ -0,0 +1,17 @@
# ---- Build Stage ----
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
RUN npm run build
# ---- Runtime Stage ----
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80