复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:16:44 +08:00
parent e2577b8cee
commit e50142a3b9
691 changed files with 97009 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Install git for repository access
RUN apk add --no-cache git ca-certificates
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Copy protocol directory first (must be before COPY . . to avoid conflicts)
# This copies protocol to /protocol, which is ../protocol relative to SERVER_DIR
COPY protocol /protocol
# Copy current directory
COPY . .
RUN echo "执行 go mod tidy..." && go mod tidy || (echo "go mod tidy 失败" && exit 1)
RUN echo "开始编译 openim-msgtransfer..." && \
go build -v -o _output/openim-msgtransfer ./cmd/openim-msgtransfer || \
(echo "编译失败,查看详细错误信息" && exit 1)
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-msgtransfer"]