mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-05 12:58:15 +08:00
* feat(build): add unified server image build flow Consolidate service image definitions into a single server build setup, and update CI workflows to use it. * fix(ci): correct Docker image tag generation
30 lines
615 B
Docker
30 lines
615 B
Docker
FROM golang:1.25-alpine AS builder
|
|
|
|
ARG CMD_PATH
|
|
ARG BINARY_NAME
|
|
ARG RELEASE=false
|
|
|
|
ENV SERVER_DIR=/openim-server
|
|
WORKDIR $SERVER_DIR
|
|
|
|
COPY . .
|
|
RUN go mod tidy
|
|
|
|
RUN if [ "$RELEASE" = "true" ]; then \
|
|
go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \
|
|
else \
|
|
go build -o _output/${BINARY_NAME} ./${CMD_PATH}; \
|
|
fi
|
|
|
|
FROM alpine:latest
|
|
|
|
RUN apk add --no-cache bash
|
|
|
|
ARG BINARY_NAME
|
|
ENV BINARY_NAME=${BINARY_NAME}
|
|
ENV SERVER_DIR=/openim-server
|
|
WORKDIR $SERVER_DIR
|
|
|
|
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
|
|
|
ENTRYPOINT ["sh", "-c", "_output/${BINARY_NAME}"] |