mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-28 14:42:14 +08:00
feat: optimize dockerfile option
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
parent
3599d4b7ef
commit
b02d65bf9a
174
.github/workflows/openimci.yml
vendored
174
.github/workflows/openimci.yml
vendored
@ -36,12 +36,12 @@ env:
|
|||||||
GO_VERSION: "1.19"
|
GO_VERSION: "1.19"
|
||||||
GOLANGCI_VERSION: "v1.50.1"
|
GOLANGCI_VERSION: "v1.50.1"
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
openim:
|
openim:
|
||||||
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
|
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
|
|
||||||
contents: write
|
contents: write
|
||||||
environment:
|
environment:
|
||||||
name: openim
|
name: openim
|
||||||
@ -52,83 +52,63 @@ jobs:
|
|||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
- name: Setup
|
||||||
uses: actions/setup-go@v4
|
uses: actions/checkout@v3
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go_version }}
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
id: go
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go_version }}
|
||||||
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Install Task
|
||||||
uses: actions/checkout@v3
|
uses: arduino/setup-task@v1
|
||||||
|
with:
|
||||||
|
version: 2.x
|
||||||
|
|
||||||
- name: Install Task
|
- name: Module Operations
|
||||||
uses: arduino/setup-task@v1
|
run: |
|
||||||
with:
|
sudo make tidy
|
||||||
version: 2.x
|
sudo make tools.verify.go-gitlint
|
||||||
|
|
||||||
- name: Run go modules tidy
|
- name: Format Code
|
||||||
run: |
|
run: sudo make format
|
||||||
sudo make tidy
|
continue-on-error: true
|
||||||
sudo make tools.verify.go-gitlint
|
|
||||||
echo "Run go modules tidy successfully"
|
|
||||||
|
|
||||||
- name: Run go format
|
- name: Generate Files
|
||||||
run: |
|
run: make gen
|
||||||
sudo make format
|
continue-on-error: true
|
||||||
echo "Run go format successfully"
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Generate all necessary files, such as error code files
|
- name: Build Source
|
||||||
run: |
|
run: sudo make build
|
||||||
make gen
|
|
||||||
echo "Generate all necessary files successfully"
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Build source code for host platform
|
- name: Cleanup Build
|
||||||
run: |
|
run: sudo make clean
|
||||||
sudo make build
|
|
||||||
echo "Build source code for host platform successfully"
|
|
||||||
|
|
||||||
- name: Clean all build
|
- name: Push Changes to Main
|
||||||
run: |
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
sudo make clean
|
with:
|
||||||
echo "Clean all build successfully"
|
commit_message: "cicd: robot automated Change"
|
||||||
|
branch: main
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
- name: push OpenIM
|
- name: Set Current Directory
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
id: set_directory
|
||||||
with:
|
run: echo "::set-output name=directory::$(pwd)"
|
||||||
commit_message: "cicd: robot automated Change"
|
continue-on-error: true
|
||||||
# commit_options: '--no-verify --signoff'
|
|
||||||
branch: main
|
|
||||||
# create_branch: true
|
|
||||||
# # Optional commit user and author settings
|
|
||||||
# commit_user_name: kubbot # defaults to "github-actions[bot]"
|
|
||||||
# commit_user_email: 3293172751ysy@gmail.com # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
# commit_author: Kubbot # defaults to author of the commit that triggered the run
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Set Current Directory
|
- name: Collect and Display Test Coverage
|
||||||
id: set_directory
|
id: collect_coverage
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=directory::$(pwd)"
|
cd ${{ steps.set_directory.outputs.directory }}
|
||||||
continue-on-error: true
|
make cover
|
||||||
|
echo "::set-output name=coverage_file::./_output/tmp/coverage.out"
|
||||||
- name: Collect Test Coverage File
|
echo "Test Coverage:"
|
||||||
id: collect_coverage
|
cat ${{ steps.collect_coverage.outputs.coverage_file }}
|
||||||
run: |
|
continue-on-error: true
|
||||||
cd ${{ steps.set_directory.outputs.directory }}
|
|
||||||
make cover
|
|
||||||
echo "::set-output name=coverage_file::./_output/tmp/coverage.out"
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Display Test Coverage
|
|
||||||
run: |
|
|
||||||
echo "Test Coverage:"
|
|
||||||
cat ${{ steps.collect_coverage.outputs.coverage_file }}
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
openim-start:
|
openim-start:
|
||||||
name: Teat OpenIM make install start on ${{ matrix.os }}
|
name: Test OpenIM install/start on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
environment:
|
environment:
|
||||||
name: openim
|
name: openim
|
||||||
@ -137,15 +117,55 @@ jobs:
|
|||||||
go_version: ["1.21"]
|
go_version: ["1.21"]
|
||||||
os: ["ubuntu-latest"]
|
os: ["ubuntu-latest"]
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
- name: Checkout and Install OpenIM
|
||||||
uses: actions/setup-go@v4
|
uses: actions/checkout@v3
|
||||||
with:
|
- name: Install Task
|
||||||
go-version: ${{ matrix.go_version }}
|
uses: arduino/setup-task@v1
|
||||||
id: go
|
with:
|
||||||
|
version: 2.x
|
||||||
|
- name: Run OpenIM make install start
|
||||||
|
run: |
|
||||||
|
sudo make install
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
execute-scripts:
|
||||||
uses: actions/checkout@v3
|
name: Execute OpenIM script on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
environment:
|
||||||
|
name: openim
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go_version: ["1.20"]
|
||||||
|
os: ["ubuntu-latest"]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run OpenIM make install start
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
run: |
|
uses: actions/setup-go@v4
|
||||||
sudo make install
|
with:
|
||||||
|
go-version: ${{ matrix.go_version }}
|
||||||
|
id: go
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v1
|
||||||
|
with:
|
||||||
|
version: 2.x
|
||||||
|
- name: Docker Operations
|
||||||
|
run: |
|
||||||
|
curl -o docker-compose.yaml https://gist.githubusercontent.com/cubxxw/b1d5cbd2edfa23fee911118aa3e8249e/raw/openim-server.sh
|
||||||
|
sudo docker compose up -d
|
||||||
|
sudo sleep 60
|
||||||
|
|
||||||
|
- name: Module Operations
|
||||||
|
run: |
|
||||||
|
sudo make tidy
|
||||||
|
sudo make tools.verify.go-gitlint
|
||||||
|
|
||||||
|
- name: Build, Start and Check Services
|
||||||
|
run: |
|
||||||
|
make build
|
||||||
|
make start
|
||||||
|
make check
|
||||||
|
|
||||||
|
- name: Print OpenIM Logs
|
||||||
|
run: sudo cat ./_output/logs/* 2>/dev/null
|
||||||
|
continue-on-error: true
|
||||||
|
|||||||
70
.github/workflows/scriptsci.yml
vendored
70
.github/workflows/scriptsci.yml
vendored
@ -1,70 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
||||||
name: OpenIM Scripts Execute CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- "docs/**"
|
|
||||||
- "README.md"
|
|
||||||
- "README_zh-CN.md"
|
|
||||||
- "CONTRIBUTING.md"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- "README.md"
|
|
||||||
- "README_zh-CN.md"
|
|
||||||
- "CONTRIBUTING.md"
|
|
||||||
- "docs/**"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
execute-scripts:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Download Docker Compose
|
|
||||||
run: |
|
|
||||||
curl -o docker-compose.yaml https://gist.githubusercontent.com/cubxxw/b1d5cbd2edfa23fee911118aa3e8249e/raw/openim-server.sh
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Start Docker Compose
|
|
||||||
run: |
|
|
||||||
sudo docker compose up -d
|
|
||||||
sudo sleep 60
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Build all services
|
|
||||||
run: |
|
|
||||||
sudo ./scripts/build-all-service.sh
|
|
||||||
|
|
||||||
- name: Start all services
|
|
||||||
run: |
|
|
||||||
sudo ./scripts/start-all.sh
|
|
||||||
|
|
||||||
- name: Check all services
|
|
||||||
run: |
|
|
||||||
sudo ./scripts/check-all.sh
|
|
||||||
|
|
||||||
- name: Print openIM.log
|
|
||||||
run: |
|
|
||||||
sudo cat ./_output/logs/* 2>/dev/null
|
|
||||||
sudo cat ./_output/logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
|
|
||||||
continue-on-error: true
|
|
||||||
@ -25,5 +25,7 @@ WORKDIR ${SERVER_WORKDIR}
|
|||||||
|
|
||||||
# Copy scripts and binary files to the production image
|
# Copy scripts and binary files to the production image
|
||||||
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
||||||
|
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
||||||
|
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
||||||
|
|
||||||
CMD ["/openim/openim-server/scripts/docker-start-all.sh"]
|
CMD ["/openim/openim-server/scripts/docker-start-all.sh"]
|
||||||
|
|||||||
47
scripts/install-im-server.sh
Executable file
47
scripts/install-im-server.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
# Common utilities, variables and checks for all build scripts.
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||||
|
|
||||||
|
trap 'openim::util::onCtrlC' INT
|
||||||
|
|
||||||
|
chmod +x ${OPENIM_ROOT}/scripts/*.sh
|
||||||
|
${OPENIM_ROOT}/scripts/init-config.sh
|
||||||
|
|
||||||
|
openim::util::ensure_docker_daemon_connectivity
|
||||||
|
|
||||||
|
DOCKER_COMPOSE_COMMAND=
|
||||||
|
# Check if docker-compose command is available
|
||||||
|
if command -v docker-compose &> /dev/null
|
||||||
|
then
|
||||||
|
openim::log::info "docker-compose command is available"
|
||||||
|
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||||
|
else
|
||||||
|
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "${OPENIM_ROOT}" >/dev/null
|
||||||
|
${DOCKER_COMPOSE_COMMAND} up -d
|
||||||
|
sleep 60
|
||||||
|
${DOCKER_COMPOSE_COMMAND} ps
|
||||||
|
${DOCKER_COMPOSE_COMMAND} logs
|
||||||
|
popd >/dev/null
|
||||||
@ -97,4 +97,4 @@ docker run -d \
|
|||||||
-e MINIO_ROOT_USER=${USER} \
|
-e MINIO_ROOT_USER=${USER} \
|
||||||
-e MINIO_ROOT_PASSWORD=${PASSWORD} \
|
-e MINIO_ROOT_PASSWORD=${PASSWORD} \
|
||||||
--restart always \
|
--restart always \
|
||||||
minio/minio server /data --console-address ':9090'
|
minio/minio server /data --console-address ':9090'
|
||||||
|
|||||||
@ -973,9 +973,6 @@ function openim::util::ensure-cfssl {
|
|||||||
popd > /dev/null || return 1
|
popd > /dev/null || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# openim::util::ensure-docker-buildx
|
|
||||||
# Check if we have "docker buildx" commands available
|
|
||||||
#
|
|
||||||
function openim::util::ensure-docker-buildx {
|
function openim::util::ensure-docker-buildx {
|
||||||
# podman returns 0 on `docker buildx version`, docker on `docker buildx`. One of them must succeed.
|
# podman returns 0 on `docker buildx version`, docker on `docker buildx`. One of them must succeed.
|
||||||
if docker buildx version >/dev/null 2>&1 || docker buildx >/dev/null 2>&1; then
|
if docker buildx version >/dev/null 2>&1 || docker buildx >/dev/null 2>&1; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user