Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.6.1-code-conventions' into 3.6…
Browse files Browse the repository at this point in the history
….1-code-conventions
  • Loading branch information
FGadvancer committed Apr 22, 2024
2 parents 820413f + 2593d25 commit 140d8d2
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Dockerfile
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"]


0 comments on commit 140d8d2

Please sign in to comment.