Skip to content

Commit fd3c19d

Browse files
committed
feat: add test file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>
1 parent ce33b79 commit fd3c19d

File tree

6 files changed

+101
-57
lines changed

6 files changed

+101
-57
lines changed

.dockerignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Ignore files and directories starting with a dot
2+
3+
# Ignore specific files
4+
.dockerignore
5+
6+
# Ignore build artifacts
7+
_output/
8+
logs/
9+
10+
# Ignore non-essential documentation
11+
README.md
12+
README-zh_CN.md
13+
CONTRIBUTING.md
14+
CHANGELOG/
15+
# LICENSE
16+
17+
# Ignore testing and linting configuration
18+
.golangci.yml
19+
20+
# Ignore deployment-related files
21+
docker-compose.yaml
22+
deployments/
23+
24+
# Ignore assets
25+
assets/
26+
27+
# Ignore components
28+
components/
29+
30+
# Ignore tools and scripts
31+
.github/
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: OpenIM Build Docker Images
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
bin:
12+
- ssserver
13+
- sslocal
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v2
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.repository_owner }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Docker metadata
26+
id: metadata
27+
uses: docker/metadata-action@v4
28+
with:
29+
images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }}
30+
- name: Build and release Docker images
31+
uses: docker/build-push-action@v3
32+
with:
33+
platforms: linux/386,linux/amd64,linux/arm64/v8
34+
target: ${{ matrix.bin }}
35+
tags: ${{ steps.metadata.outputs.tags }}
36+
push: true

.github/workflows/openim-ci.yml

+1-20
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383

8484
- name: Build source code for host platform
8585
run: |
86-
make multiarch
86+
make build
8787
echo "Build source code for host platform successfully"
8888
8989
# - name: Collect Test Coverage File
@@ -132,22 +132,3 @@ jobs:
132132
# - name: Test docker image
133133
# run: |
134134
# docker build -t openim:ci-build .
135-
136-
# goreleaser-test:
137-
# runs-on: ubuntu-20.04
138-
# steps:
139-
# - name: Checkout
140-
# uses: actions/checkout@v3
141-
# with:
142-
# fetch-depth: 0
143-
144-
# - name: Set up Go
145-
# uses: actions/setup-go@v3
146-
# with:
147-
# go-version: ${{ env.GO_VERSION }}
148-
149-
# - name: Run GoReleaser
150-
# uses: goreleaser/goreleaser-action@v4
151-
# with:
152-
# version: latest
153-
# args: release --clean --skip-publish --snapshot

Dockerfile

+27-23
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1+
# Build Stage
12
FROM golang as build
23

3-
# go mod Installation source, container environment variable addition will override the default variable value
4-
ENV GO111MODULE=on
5-
ENV GOPROXY=https://goproxy.cn,direct
4+
# Set go mod installation source and proxy
5+
ARG GO111MODULE=on
6+
ARG GOPROXY=https://goproxy.cn,direct
7+
ENV GO111MODULE=$GO111MODULE
8+
ENV GOPROXY=$GOPROXY
69

710
# Set up the working directory
811
WORKDIR /Open-IM-Server
9-
# add all files to the container
10-
COPY . .
1112

12-
WORKDIR /Open-IM-Server/scripts
13-
RUN chmod +x *.sh
14-
15-
RUN /bin/sh -c ./build_all_service.sh
13+
# Copy all files to the container
14+
ADD . .
1615

17-
#Blank image Multi-Stage Build
18-
FROM ubuntu
16+
RUN /bin/sh -c "make build"
1917

20-
RUN rm -rf /var/lib/apt/lists/*
21-
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
22-
&&apt-get install net-tools
23-
#Non-interactive operation
24-
ENV DEBIAN_FRONTEND=noninteractive
25-
RUN apt-get install -y vim curl tzdata gawk
26-
#Time zone adjusted to East eighth District
27-
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
18+
# Production Stage
19+
FROM alpine
2820

21+
RUN apk --no-cache add tzdata
2922

30-
#set directory to map logs,config file,scripts file.
31-
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts","/Open-IM-Server/db/sdk"]
23+
# Set directory to map logs, config files, scripts, and SDK
24+
VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"]
3225

33-
#Copy scripts files and binary files to the blank image
26+
# Copy scripts and binary files to the production image
3427
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
35-
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64
28+
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/arm64 /Open-IM-Server/_output/bin/platforms/linux/arm64
3629

3730
WORKDIR /Open-IM-Server/scripts
3831

3932
CMD ["./docker_start_all.sh"]
33+
34+
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
35+
.PHONY: docker-buildx
36+
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
37+
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
38+
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
39+
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
40+
$(CONTAINER_TOOL) buildx use project-v3-builder
41+
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
42+
- $(CONTAINER_TOOL) buildx rm project-v3-builder
43+
rm Dockerfile.cross

docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ services:
100100

101101

102102
openim_server:
103-
image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.0
103+
image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.1
104104
container_name: openim-server
105105
volumes:
106106
- ./logs:/Open-IM-Server/logs

scripts/build_all_service.sh

+5-13
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,19 @@ echo -e "${BOLD_PREFIX}_________________________________________________________
3737
bin_dir="$BIN_DIR"
3838
logs_dir="$OPENIM_ROOT/logs"
3939
sdk_db_dir="$OPENIM_ROOT/db/sdk/"
40+
41+
echo "==> bin_dir=$bin_dir"
42+
echo "==> logs_dir=$logs_dir"
43+
echo "==> sdk_db_dir=$sdk_db_dir"
44+
4045
# Automatically created when there is no bin, logs folder
41-
if [ ! -d $bin_dir ]; then
42-
mkdir -p $bin_dir
43-
fi
4446
if [ ! -d $logs_dir ]; then
4547
mkdir -p $logs_dir
4648
fi
4749
if [ ! -d $sdk_db_dir ]; then
4850
mkdir -p $sdk_db_dir
4951
fi
5052

51-
#Include shell font styles and some basic information
52-
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
53-
54-
echo "PWD=================>$PWD"
55-
56-
#Include shell font styles and some basic information
57-
source ./style_info.sh
58-
source ./path_info.sh
59-
source ./function.sh
60-
6153
cd $OPENIM_ROOT
6254

6355
# Execute 'make build'

0 commit comments

Comments
 (0)