dsx137 8f913ca13b
refactor(ci): actions and dockerfile (#3732)
* 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
2026-06-04 10:09:07 +00:00

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}"]