ARG VERSION FROM golang:latest as builder MAINTAINER sk WORKDIR /projects/go COPY ./framework-1.0.21 ./framework-1.0.21 WORKDIR ./ecs 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 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 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 event FROM alpine:latest as ecs_user WORKDIR /app/ecs/user COPY --from=builder /projects/go/ecs/build/bin/ecs_user ./bin/ecs_user COPY ./build/servers/user/conf/user.json ./conf/user.json CMD ./bin/ecs_user -conf /var/lib/ecs/user/conf/user.json # Target event FROM alpine:latest as event WORKDIR /app/ecs/event COPY --from=builder /projects/go/ecs/build/bin/ecs_event ./bin/ecs_event COPY ./build/servers/event/conf/event.json ./conf/event.json CMD ./bin/ecs_event -conf /var/lib/ecs/event/conf/event.json # 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 COPY ./build/servers/game/conf/game.json ./conf/game.json CMD ./bin/ecs_game -conf /var/lib/ecs/game/conf/game.json # Target gate FROM alpine:latest as gate WORKDIR /app/ecs/gate COPY --from=builder /projects/go/ecs/build/bin/ecs_gate ./bin/ecs_gate COPY ./build/servers/gate/conf/gate.json ./conf/gate.json CMD ./bin/ecs_gate -conf /var/lib/ecs/gate/conf/gate.json