ecs/Dockerfile

66 lines
1.6 KiB
Docker
Raw Normal View History

2025-06-04 18:17:39 +08:00
ARG VERSION
2025-07-16 10:05:22 +08:00
FROM golang:latest AS builder
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
MAINTAINER sk
2025-06-04 18:17:39 +08:00
WORKDIR /projects/go
2025-07-16 10:05:22 +08:00
COPY framework/ framework/
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
COPY ecs/ ecs/
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
WORKDIR /projects/go/ecs
2025-06-04 18:17:39 +08:00
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
2025-07-16 10:05:22 +08:00
RUN go mod tidy
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_center ./servers/user
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_event ./servers/event
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_game ./servers/game
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_gate ./servers/gate
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
# Target user
FROM alpine:latest AS ezs_user
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
WORKDIR /app/ecs/user
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
COPY --from=builder /projects/go/ecs/build/bin/ezs_user ./bin/ezs_user
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
CMD ./bin/ezs_user -help
2025-06-04 18:17:39 +08:00
# Target event
2025-07-16 10:05:22 +08:00
FROM alpine:latest AS ezs_event
2025-06-04 18:17:39 +08:00
WORKDIR /app/ecs/event
2025-07-16 10:05:22 +08:00
COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
CMD ./bin/ezs_event -help
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
# Target game
FROM alpine:latest AS ezs_game
2025-06-04 18:17:39 +08:00
WORKDIR /app/ecs/game
2025-07-16 10:05:22 +08:00
COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
CMD ./bin/ezs_game -help
2025-06-04 18:17:39 +08:00
# Target gate
2025-07-16 10:05:22 +08:00
FROM alpine:latest AS ezs_gate
2025-06-04 18:17:39 +08:00
WORKDIR /app/ecs/gate
2025-07-16 10:05:22 +08:00
COPY --from=builder /projects/go/ecs/build/bin/ezs_gate ./bin/ezs_gate
2025-06-04 18:17:39 +08:00
2025-07-16 10:05:22 +08:00
CMD ./bin/ezs_gate -help