Skip to content

Commit e4003e6

Browse files
committed
Merge: main
2 parents 913d4c5 + 120afdf commit e4003e6

File tree

79 files changed

+1853
-1006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1853
-1006
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build and release services Images
2+
3+
on:
4+
push:
5+
branches:
6+
- release-*
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "Tag version to be used for Docker image"
13+
required: true
14+
default: "v3.8.3"
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v2
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Log in to Aliyun Container Registry
41+
uses: docker/login-action@v2
42+
with:
43+
registry: registry.cn-hangzhou.aliyuncs.com
44+
username: ${{ secrets.ALIREGISTRY_USERNAME }}
45+
password: ${{ secrets.ALIREGISTRY_TOKEN }}
46+
47+
- name: Extract metadata for Docker (tags, labels)
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
tags: |
52+
type=ref,event=tag
53+
type=schedule
54+
type=ref,event=branch
55+
type=semver,pattern={{version}}
56+
type=semver,pattern=v{{version}}
57+
# type=semver,pattern={{major}}.{{minor}}
58+
type=semver,pattern=release-{{raw}}
59+
type=sha
60+
type=raw,value=${{ github.event.inputs.tag }}
61+
62+
- name: Build and push Docker images
63+
run: |
64+
ROOT_DIR="build/images"
65+
for dir in "$ROOT_DIR"/*/; do
66+
# Find Dockerfile or *.dockerfile in a case-insensitive manner
67+
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
68+
69+
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
70+
IMAGE_NAME=$(basename "$dir")
71+
echo "Building Docker image for $IMAGE_NAME with tags:"
72+
73+
# Initialize tag arguments
74+
tag_args=()
75+
76+
# Read each tag and append --tag arguments
77+
while IFS= read -r tag; do
78+
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
79+
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
80+
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
81+
done <<< "${{ steps.meta.outputs.tags }}"
82+
83+
# Build and push the Docker image with all tags
84+
docker buildx build --platform linux/amd64,linux/arm64 \
85+
--file "$dockerfile" \
86+
"${tag_args[@]}" \
87+
--push "$dir"
88+
else
89+
echo "No valid Dockerfile found in $dir"
90+
fi
91+
done

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
4343
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
4444
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
4545

46-
RUN go get github.com/openimsdk/[email protected].14-alpha.5
46+
RUN go get github.com/openimsdk/[email protected].15-alpha.1
4747

4848
# Set the command to run when the container starts
4949
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]

build/images/Dockerfile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Copyright © 2023 OpenIM. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
# # Copyright © 2023 OpenIM. All rights reserved.
2+
# #
3+
# # Licensed under the Apache License, Version 2.0 (the "License");
4+
# # you may not use this file except in compliance with the License.
5+
# # You may obtain a copy of the License at
6+
# #
7+
# # http://www.apache.org/licenses/LICENSE-2.0
8+
# #
9+
# # Unless required by applicable law or agreed to in writing, software
10+
# # distributed under the License is distributed on an "AS IS" BASIS,
11+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# # See the License for the specific language governing permissions and
13+
# # limitations under the License.
1414

15-
FROM BASE_IMAGE
15+
# FROM BASE_IMAGE
1616

17-
WORKDIR ${SERVER_WORKDIR}
17+
# WORKDIR ${SERVER_WORKDIR}
1818

19-
# Set HTTP proxy
20-
ARG BINARY_NAME
19+
# # Set HTTP proxy
20+
# ARG BINARY_NAME
2121

22-
COPY BINARY_NAME ./bin/BINARY_NAME
22+
# COPY BINARY_NAME ./bin/BINARY_NAME
2323

24-
ENTRYPOINT ["./bin/BINARY_NAME"]
24+
# ENTRYPOINT ["./bin/BINARY_NAME"]

build/images/openim-api/Dockerfile

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,36 @@
1-
# Copyright © 2023 OpenIM. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
# Use Go 1.22 Alpine as the base image for building the application
2+
FROM golang:1.22-alpine AS builder
143

15-
# OpenIM base image: https://github.com/openim-sigs/openim-base-image
4+
# Define the base directory for the application as an environment variable
5+
ENV SERVER_DIR=/openim-server
166

17-
# Set go mod installation source and proxy
7+
# Set the working directory inside the container based on the environment variable
8+
WORKDIR $SERVER_DIR
189

19-
FROM golang:1.20 AS builder
10+
# Set the Go proxy to improve dependency resolution speed
11+
#ENV GOPROXY=https://goproxy.io,direct
2012

21-
ARG GO111MODULE=on
22-
23-
WORKDIR /openim/openim-server
24-
25-
ENV GO111MODULE=$GO111MODULE
26-
ENV GOPROXY=$GOPROXY
13+
# Copy all files from the current directory into the container
14+
COPY . .
2715

28-
COPY go.mod go.sum ./
29-
RUN go mod download
16+
RUN go mod tidy
3017

31-
COPY . .
18+
RUN go build -o _output/openim-api ./cmd/openim-api
3219

33-
RUN make build BINS=openim-api
20+
# Using Alpine Linux for the final image
21+
FROM alpine:latest
3422

35-
RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-api /usr/bin/openim-api
23+
# Install necessary packages, such as bash
24+
RUN apk add --no-cache bash
3625

37-
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
38-
FROM ghcr.io/openim-sigs/openim-bash-image:latest
26+
# Set the environment and work directory
27+
ENV SERVER_DIR=/openim-server
28+
WORKDIR $SERVER_DIR
3929

40-
WORKDIR /openim/openim-server
4130

42-
COPY --from=builder /usr/bin/openim-api ./bin/openim-api
31+
# Copy the compiled binaries and mage from the builder image to the final image
32+
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
33+
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
4334

44-
ENTRYPOINT ["./bin/openim-api"]
35+
# Set the command to run when the container starts
36+
ENTRYPOINT ["sh", "-c", "_output/openim-api"]

build/images/openim-cmdutils/Dockerfile

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
# Copyright © 2023 OpenIM. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
# Use Go 1.22 Alpine as the base image for building the application
2+
FROM golang:1.22-alpine AS builder
3+
# Define the base directory for the application as an environment variable
4+
ENV SERVER_DIR=/openim-server
145

15-
# OpenIM base image: https://github.com/openim-sigs/openim-base-image
6+
# Set the working directory inside the container based on the environment variable
7+
WORKDIR $SERVER_DIR
168

17-
# Set go mod installation source and proxy
9+
# Set the Go proxy to improve dependency resolution speed
1810

19-
FROM golang:1.20 AS builder
11+
#ENV GOPROXY=https://goproxy.io,direct
2012

21-
ARG GO111MODULE=on
13+
# Copy all files from the current directory into the container
14+
COPY . .
2215

23-
WORKDIR /openim/openim-server
16+
RUN go mod tidy
2417

25-
ENV GO111MODULE=$GO111MODULE
26-
ENV GOPROXY=$GOPROXY
2718

28-
COPY go.mod go.sum ./
29-
RUN go mod download
3019

31-
COPY . .
20+
RUN go build -o _output/openim-crontask ./cmd/openim-crontask
21+
3222

33-
RUN make build BINS=openim-crontask
23+
# Using Alpine Linux for the final image
24+
FROM alpine:latest
3425

35-
RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-crontask /usr/bin/openim-crontask
26+
# Install necessary packages, such as bash
27+
RUN apk add --no-cache bash
3628

37-
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
38-
FROM ghcr.io/openim-sigs/openim-bash-image:latest
29+
# Set the environment and work directory
30+
ENV SERVER_DIR=/openim-server
31+
WORKDIR $SERVER_DIR
3932

40-
WORKDIR /openim/openim-server
4133

42-
COPY --from=builder /usr/bin/openim-crontask ./bin/openim-crontask
34+
# Copy the compiled binaries and mage from the builder image to the final image
35+
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
36+
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
4337

44-
ENTRYPOINT ["./bin/openim-crontask"]
38+
# Set the command to run when the container starts
39+
ENTRYPOINT ["sh", "-c", "_output/openim-crontask"]

0 commit comments

Comments
 (0)