ecs/Dockerfile

79 lines
2.2 KiB
Docker
Raw Normal View History

2025-06-04 18:17:39 +08:00
ARG VERSION
FROM golang:latest as builder
2025-06-20 16:14:30 +08:00
MAINTAINER sk
2025-06-04 18:17:39 +08:00
WORKDIR /projects/go
2025-06-20 16:14:30 +08:00
COPY ./framework-1.0.21 ./framework-1.0.21
2025-06-04 18:17:39 +08:00
WORKDIR ./ecs
2025-06-20 16:14:30 +08:00
COPY ./platform ./platform
COPY ./proto/*.go ./proto/*.gg
COPY ./proto/pb ./proto/pb
COPY ./servers/user ./servers/user
COPY ./servers/event ./servers/event
COPY ./servers/game ./servers/game
COPY ./servers/gate ./servers/gate
COPY ./go.mod ./go.mod
COPY ./go.sum ./go.sum
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
RUN go mod download
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_center ./servers/center
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_event ./servers/event
2025-06-20 16:14:30 +08:00
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_game ./servers/game
2025-06-04 18:17:39 +08:00
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_gate ./servers/gate
# Target event
2025-06-20 16:14:30 +08:00
FROM alpine:latest as ecs_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-06-20 16:14:30 +08:00
COPY --from=builder /projects/go/ecs/build/bin/ecs_user ./bin/ecs_user
COPY ./build/servers/user/conf/user.json ./conf/user.json
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
CMD ./bin/ecs_user -conf /var/lib/ecs/user/conf/user.json
2025-06-04 18:17:39 +08:00
# Target event
FROM alpine:latest as event
WORKDIR /app/ecs/event
COPY --from=builder /projects/go/ecs/build/bin/ecs_event ./bin/ecs_event
2025-06-20 16:14:30 +08:00
COPY ./build/servers/event/conf/event.json ./conf/event.json
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
CMD ./bin/ecs_event -conf /var/lib/ecs/event/conf/event.json
2025-06-04 18:17:39 +08:00
# Target game_1
FROM alpine:latest as game
WORKDIR /app/ecs/game
COPY --from=builder /projects/go/ecs/build/bin/ecs_game ./bin/ecs_game
2025-06-20 16:14:30 +08:00
COPY ./build/servers/game/conf/game.json ./conf/game.json
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
CMD ./bin/ecs_game -conf /var/lib/ecs/game/conf/game.json
2025-06-04 18:17:39 +08:00
# Target gate
FROM alpine:latest as gate
WORKDIR /app/ecs/gate
COPY --from=builder /projects/go/ecs/build/bin/ecs_gate ./bin/ecs_gate
2025-06-20 16:14:30 +08:00
COPY ./build/servers/gate/conf/gate.json ./conf/gate.json
2025-06-04 18:17:39 +08:00
2025-06-20 16:14:30 +08:00
CMD ./bin/ecs_gate -conf /var/lib/ecs/gate/conf/gate.json