diff --git a/deploy/Dockerfile.gateway b/deploy/Dockerfile.gateway index de3f122..22aae9e 100644 --- a/deploy/Dockerfile.gateway +++ b/deploy/Dockerfile.gateway @@ -1,7 +1,15 @@ -FROM alpine:3.19 +FROM golang:1.24-alpine AS builder +RUN apk add --no-cache git +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server ./gateway/gateway.go + +FROM alpine:3.20 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app -COPY deploy/bin/gateway . +COPY --from=builder /server ./gateway COPY deploy/etc/gateway.yaml etc/gateway.yaml EXPOSE 8888 CMD ["./gateway", "-f", "etc/gateway.yaml"] diff --git a/deploy/Dockerfile.inventory b/deploy/Dockerfile.inventory index 80ede24..a056444 100644 --- a/deploy/Dockerfile.inventory +++ b/deploy/Dockerfile.inventory @@ -1,7 +1,15 @@ -FROM alpine:3.19 +FROM golang:1.24-alpine AS builder +RUN apk add --no-cache git +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server ./rpc/inventory/inventory.go + +FROM alpine:3.20 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app -COPY deploy/bin/inventory . +COPY --from=builder /server ./inventory COPY deploy/etc/inventory.yaml etc/inventory.yaml EXPOSE 9002 CMD ["./inventory", "-f", "etc/inventory.yaml"] diff --git a/deploy/Dockerfile.system b/deploy/Dockerfile.system index e27367e..b939a03 100644 --- a/deploy/Dockerfile.system +++ b/deploy/Dockerfile.system @@ -1,7 +1,15 @@ -FROM alpine:3.19 +FROM golang:1.24-alpine AS builder +RUN apk add --no-cache git +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server ./rpc/system/system.go + +FROM alpine:3.20 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app -COPY deploy/bin/system . +COPY --from=builder /server ./system COPY deploy/etc/system.yaml etc/system.yaml EXPOSE 9001 CMD ["./system", "-f", "etc/system.yaml"] diff --git a/deploy/docker-compose.yaml b/deploy/docker-compose.yaml index 397e2a7..33d00c1 100644 --- a/deploy/docker-compose.yaml +++ b/deploy/docker-compose.yaml @@ -8,7 +8,7 @@ services: MYSQL_DATABASE: muyu_wms TZ: Asia/Shanghai ports: - - "3306:3306" + - "${MYSQL_PORT:-13306}:3306" volumes: - ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql - ../data/mysql:/var/lib/mysql @@ -24,7 +24,7 @@ services: container_name: muyu-redis restart: always ports: - - "6379:6379" + - "${REDIS_PORT:-16379}:6379" volumes: - ../data/redis:/data healthcheck: @@ -127,7 +127,7 @@ services: container_name: muyu-nginx restart: always ports: - - "8080:80" + - "${NGINX_PORT:-18080}:80" volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf - ../../muyu-portal/dist:/usr/share/nginx/html