You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/build/images/openim-server/Dockerfile

31 lines
602 B

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 \
RUN go build -o myapp ./cmd/server; \
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}"]