Merge remote-tracking branch 'origin/3.6.1-code-conventions' into 3.6.1-code-conventions

pull/2202/head
Gordon 1 year ago
commit 140d8d2fca

@ -1,28 +1,37 @@
# Use Go 1.21 as the base image
# Use Go 1.21 as the base image for building the application
FROM golang:1.21 as builder
# Set the working directory
# Set the working directory inside the container
WORKDIR /openim-server
# Set the Go proxy to improve dependency resolution speed
ENV GOPROXY=https://goproxy.cn,direct
# Copy all files from the current directory to the image
# Copy all files from the current directory into the container
COPY . .
# Execute the script and build command
# Execute the script and build command, including downloading mage
RUN chmod +x ./bootstrap.sh && \
./bootstrap.sh && \
mage build
# Use scratch as the base image for the minimal production image
FROM scratch
# Use Alpine Linux as the final base image due to its small size and included utilities
FROM alpine:latest
# Copy the compiled binaries from the builder image to the production image
# Install necessary packages, such as bash, to ensure compatibility and functionality
RUN apk add --no-cache bash
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder /openim-server/_output /openim-server/_output
COPY --from=builder /root/go/bin/mage /usr/local/bin/mage
# Set the working directory
# Set the working directory to /openim-server within the container
WORKDIR /openim-server
# Set up volume mounts for the config directory and logs directory
# Set up volume mounts for the configuration directory and logs directory
VOLUME ["/openim-server/config", "/openim-server/_output/logs"]
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]

Loading…
Cancel
Save