复制项目
This commit is contained in:
39
build/images/openim-chat-rpc/Dockerfile
Normal file
39
build/images/openim-chat-rpc/Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
||||
# 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 CHAT_DIR=/openim-chat
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $CHAT_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
# Use container's existing SSH configuration for private repositories
|
||||
RUN go mod tidy
|
||||
RUN go build -o _output/chat-rpc ./cmd/rpc/chat-rpc
|
||||
|
||||
# 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 CHAT_DIR=/openim-chat
|
||||
WORKDIR $CHAT_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $CHAT_DIR/_output $CHAT_DIR/_output
|
||||
COPY --from=builder $CHAT_DIR/config $CHAT_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/chat-rpc"]
|
||||
Reference in New Issue
Block a user