复制项目
This commit is contained in:
24
build/images/Dockerfile
Normal file
24
build/images/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# # Copyright © 2023 OpenIM. 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"]
|
||||
42
build/images/openim-api/Dockerfile
Normal file
42
build/images/openim-api/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory first (must be before COPY . . to avoid conflicts)
|
||||
# This copies protocol to /protocol, which is ../protocol relative to SERVER_DIR
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN echo "执行 go mod tidy..." && go mod tidy || (echo "go mod tidy 失败" && exit 1)
|
||||
|
||||
RUN echo "开始编译 openim-api..." && \
|
||||
go build -v -o _output/openim-api ./cmd/openim-api || \
|
||||
(echo "编译失败,查看详细错误信息" && exit 1)
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-api"]
|
||||
42
build/images/openim-crontask/Dockerfile
Normal file
42
build/images/openim-crontask/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-crontask ./cmd/openim-crontask
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-crontask"]
|
||||
43
build/images/openim-msggateway/Dockerfile
Normal file
43
build/images/openim-msggateway/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory first (must be before COPY . . to avoid conflicts)
|
||||
# This copies protocol to /protocol, which is ../protocol relative to SERVER_DIR
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN echo "执行 go mod tidy..." && go mod tidy || (echo "go mod tidy 失败" && exit 1)
|
||||
|
||||
RUN echo "开始编译 openim-msggateway..." && \
|
||||
go build -v -o _output/openim-msggateway ./cmd/openim-msggateway || \
|
||||
(echo "编译失败,查看详细错误信息" && exit 1)
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-msggateway"]
|
||||
43
build/images/openim-msgtransfer/Dockerfile
Normal file
43
build/images/openim-msgtransfer/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory first (must be before COPY . . to avoid conflicts)
|
||||
# This copies protocol to /protocol, which is ../protocol relative to SERVER_DIR
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN echo "执行 go mod tidy..." && go mod tidy || (echo "go mod tidy 失败" && exit 1)
|
||||
|
||||
RUN echo "开始编译 openim-msgtransfer..." && \
|
||||
go build -v -o _output/openim-msgtransfer ./cmd/openim-msgtransfer || \
|
||||
(echo "编译失败,查看详细错误信息" && exit 1)
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-msgtransfer"]
|
||||
43
build/images/openim-push/Dockerfile
Normal file
43
build/images/openim-push/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory first (must be before COPY . . to avoid conflicts)
|
||||
# This copies protocol to /protocol, which is ../protocol relative to SERVER_DIR
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN echo "执行 go mod tidy..." && go mod tidy || (echo "go mod tidy 失败" && exit 1)
|
||||
|
||||
RUN echo "开始编译 openim-push..." && \
|
||||
go build -v -o _output/openim-push ./cmd/openim-push || \
|
||||
(echo "编译失败,查看详细错误信息" && exit 1)
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-push"]
|
||||
42
build/images/openim-rpc-auth/Dockerfile
Normal file
42
build/images/openim-rpc-auth/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-auth"]
|
||||
42
build/images/openim-rpc-conversation/Dockerfile
Normal file
42
build/images/openim-rpc-conversation/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-rpc-conversation ./cmd/openim-rpc/openim-rpc-conversation
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-conversation"]
|
||||
42
build/images/openim-rpc-friend/Dockerfile
Normal file
42
build/images/openim-rpc-friend/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-rpc-friend ./cmd/openim-rpc/openim-rpc-friend
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-friend"]
|
||||
42
build/images/openim-rpc-group/Dockerfile
Normal file
42
build/images/openim-rpc-group/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-rpc-group ./cmd/openim-rpc/openim-rpc-group
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-group"]
|
||||
64
build/images/openim-rpc-msg/Dockerfile
Normal file
64
build/images/openim-rpc-msg/Dockerfile
Normal file
@@ -0,0 +1,64 @@
|
||||
# Use Go 1.22 Alpine as the base image for building the application
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
# Install git, build tools and dependencies for Quirc
|
||||
RUN apk add --no-cache git ca-certificates build-base make gcc musl-dev pkgconfig
|
||||
|
||||
# Build and install Quirc library (static library)
|
||||
RUN cd /tmp && \
|
||||
git clone --depth 1 https://github.com/dlbeer/quirc.git && \
|
||||
cd quirc && \
|
||||
sed -i 's/\$(shell pkg-config --cflags sdl 2>&1)/\$(shell pkg-config --cflags sdl 2>\/dev\/null || true)/g' Makefile && \
|
||||
sed -i 's/\$(shell pkg-config --libs sdl)/\$(shell pkg-config --libs sdl 2>\/dev\/null || true)/g' Makefile && \
|
||||
sed -i 's/\$(shell pkg-config --cflags opencv4 2>&1)/\$(shell pkg-config --cflags opencv4 2>\/dev\/null || true)/g' Makefile && \
|
||||
sed -i 's/\$(shell pkg-config --libs opencv4)/\$(shell pkg-config --libs opencv4 2>\/dev\/null || true)/g' Makefile && \
|
||||
make libquirc.a && \
|
||||
mkdir -p /usr/local/lib /usr/local/include && \
|
||||
cp libquirc.a /usr/local/lib/ && \
|
||||
cp lib/quirc.h /usr/local/include/ && \
|
||||
ls -la /usr/local/lib/libquirc.a /usr/local/include/quirc.h && \
|
||||
rm -rf /tmp/quirc
|
||||
|
||||
# Define the base directory for the application as an environment variable
|
||||
ENV SERVER_DIR=/openim-server
|
||||
ENV CGO_ENABLED=1
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
# Build with static linking for Quirc (静态链接,运行时无需库文件)
|
||||
# 使用 -ldflags 强制静态链接 Quirc 库和数学库
|
||||
# 注意:Alpine Linux 使用 musl libc,需要静态链接数学库
|
||||
RUN go build -tags cgo \
|
||||
-ldflags '-linkmode external -extldflags "-static -L/usr/local/lib -lquirc -lm"' \
|
||||
-o _output/openim-rpc-msg ./cmd/openim-rpc/openim-rpc-msg && \
|
||||
echo "构建完成,验证二进制文件..." && \
|
||||
file _output/openim-rpc-msg && \
|
||||
ldd _output/openim-rpc-msg 2>&1 | head -5 || echo "静态链接验证:二进制文件不依赖动态库(这是正常的)"
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-msg"]
|
||||
42
build/images/openim-rpc-third/Dockerfile
Normal file
42
build/images/openim-rpc-third/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
|
||||
|
||||
RUN go build -o _output/openim-rpc-third ./cmd/openim-rpc/openim-rpc-third
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-third"]
|
||||
40
build/images/openim-rpc-user/Dockerfile
Normal file
40
build/images/openim-rpc-user/Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Copy protocol directory
|
||||
COPY protocol /protocol
|
||||
|
||||
# Copy current directory
|
||||
COPY . .
|
||||
|
||||
RUN go mod tidy
|
||||
|
||||
RUN go build -o _output/openim-rpc-user ./cmd/openim-rpc/openim-rpc-user
|
||||
|
||||
|
||||
# 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 SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-user"]
|
||||
108
build/images/openim-tools/component/Dockerfile
Normal file
108
build/images/openim-tools/component/Dockerfile
Normal file
@@ -0,0 +1,108 @@
|
||||
# # Copyright © 2023 OpenIM. 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.
|
||||
|
||||
# # OpenIM base image: https://github.com/openim-sigs/openim-base-image
|
||||
|
||||
# # Set go mod installation source and proxy
|
||||
|
||||
# FROM golang:1.20 AS builder
|
||||
|
||||
#
|
||||
|
||||
# WORKDIR /openim/openim-server
|
||||
|
||||
#
|
||||
# ENV GOPROXY=$GOPROXY
|
||||
|
||||
# COPY go.mod go.sum ./
|
||||
# RUN go mod download
|
||||
|
||||
# COPY . .
|
||||
|
||||
# RUN make clean
|
||||
# RUN make build BINS=component
|
||||
|
||||
# # FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||
|
||||
# WORKDIR /openim/openim-server
|
||||
|
||||
# COPY --from=builder /openim/openim-server/_output/bin/tools /openim/openim-server/_output/bin/tools/
|
||||
# COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
||||
|
||||
# ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config
|
||||
|
||||
# RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component
|
||||
|
||||
# ENTRYPOINT ["bash", "-c", "component -c $OPENIM_SERVER_CONFIG_NAME"]
|
||||
|
||||
|
||||
# Use Go 1.22 Alpine as the base image for building the application
|
||||
FROM golang:1.22-alpine AS builder
|
||||
# Define the base directory for the application as an environment variable
|
||||
ENV SERVER_DIR=/openim-server
|
||||
|
||||
# Set the working directory inside the container based on the environment variable
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
# Set the Go proxy to improve dependency resolution speed
|
||||
|
||||
#ENV GOPROXY=https://goproxy.io,direct
|
||||
|
||||
# Copy all files from the current directory into the container
|
||||
COPY . .
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Install Mage to use for building the application
|
||||
RUN go install github.com/magefile/mage@v1.15.0
|
||||
|
||||
# ENV BINS=openim-rpc-user
|
||||
|
||||
# Optionally build your application if needed
|
||||
# RUN mage build ${BINS} check-free-memory seq || true
|
||||
RUN mage build check-free-memory seq || true
|
||||
|
||||
# Using Alpine Linux with Go environment for the final image
|
||||
FROM golang:1.22-alpine
|
||||
|
||||
# Install necessary packages, such as bash
|
||||
RUN apk add bash
|
||||
|
||||
# Set the environment and work directory
|
||||
ENV SERVER_DIR=/openim-server
|
||||
WORKDIR $SERVER_DIR
|
||||
|
||||
|
||||
# Copy the compiled binaries and mage from the builder image to the final image
|
||||
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
|
||||
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
|
||||
COPY --from=builder /go/bin/mage /usr/local/bin/mage
|
||||
COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/
|
||||
COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/
|
||||
COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/
|
||||
# COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
|
||||
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
|
||||
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
|
||||
|
||||
|
||||
RUN echo -e "serviceBinaries:\n \n" \
|
||||
> $SERVER_DIR/start-config.yml && \
|
||||
echo -e "toolBinaries:\n - check-free-memory\n - seq\n" >> $SERVER_DIR/start-config.yml && \
|
||||
echo "maxFileDescriptors: 10000" >> $SERVER_DIR/start-config.yml
|
||||
|
||||
RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.1
|
||||
|
||||
# Set the command to run when the container starts
|
||||
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
|
||||
Reference in New Issue
Block a user