复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:35:45 +08:00
parent 305d526110
commit b7f8db7d08
297 changed files with 81784 additions and 0 deletions

24
build/images/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM BASE_IMAGE
WORKDIR ${SERVER_WORKDIR}
# Set HTTP proxy
ARG BINARY_NAME
COPY BINARY_NAME ./bin/BINARY_NAME
ENTRYPOINT ["./bin/BINARY_NAME"]

View 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/admin-api ./cmd/api/admin-api
# 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/admin-api"]

View 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/admin-rpc ./cmd/rpc/admin-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/admin-rpc"]

View File

@@ -0,0 +1,51 @@
# 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
# Build arguments to invalidate cache when code changes
ARG BUILD_SHA
ARG BUILD_TIME
ENV BUILD_SHA=$BUILD_SHA
ENV BUILD_TIME=$BUILD_TIME
# Copy protocol directory
COPY protocol /protocol
# Copy go mod files first for better caching
COPY go.mod go.sum ./
# Download dependencies (this layer will be cached if go.mod/go.sum don't change)
RUN go mod download
# Copy current directory (this will invalidate cache when code changes)
COPY . .
# Use container's existing SSH configuration for private repositories
RUN go mod tidy
RUN go build -o _output/chat-api ./cmd/api/chat-api
# 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-api"]

View 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"]