forked from openimsdk/open-im-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/3.6.1-code-conventions' into 3.6…
….1-code-conventions
- Loading branch information
Showing
1 changed file
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
|
||
|