ecs/Dockerfile

83 lines
2.0 KiB
Docker
Raw Permalink 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-18 10:45:29 +08:00
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_center ./servers/user
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_event ./servers/event
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_game ./servers/game
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_gate ./servers/gate
# Target ecs
FROM alpine:latest AS ecs
WORKDIR /app/ecs
COPY --from=builder /projects/go/ecs/app.sh app.sh
RUN chmod +x ./app.sh
COPY --from=builder /projects/go/ecs/build/bin/ecs_user user/bin/ecs_user
COPY --from=builder /projects/go/ecs/build/bin/ecs_event event/bin/ecs_event
COPY --from=builder /projects/go/ecs/build/bin/ecs_game game/bin/ecs_game
COPY --from=builder /projects/go/ecs/build/bin/ecs_gate gate/bin/ecs_gate
CMD ./app.sh help
## Target user
#FROM alpine:latest AS ecs_user
#
#WORKDIR /app/ecs/user
#
#COPY --from=builder /projects/go/ecs/build/bin/ecs_user ./bin/ecs_user
#
#CMD ./bin/ecs_user -help
#
#
## Target event
#FROM alpine:latest AS ezs_event
#
#WORKDIR /app/ecs/event
#
#COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event
#
#CMD ./bin/ezs_event -help
#
#
## Target game
#FROM alpine:latest AS ezs_game
#
#WORKDIR /app/ecs/game
#
#COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game
#
#CMD ./bin/ezs_game -help
#
## Target gate
#FROM alpine:latest AS ezs_gate
#
#WORKDIR /app/ecs/gate
#
#COPY --from=builder /projects/go/ecs/build/bin/ezs_gate ./bin/ezs_gate
#
#CMD ./bin/ezs_gate -help