mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-10 23:07:30 +08:00
feat: fix openim ci and deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
parent
035afff03e
commit
f72e41207f
9
.github/workflows/build-docker-image.yml
vendored
9
.github/workflows/build-docker-image.yml
vendored
@ -120,6 +120,15 @@ jobs:
|
||||
uses: docker/metadata-action@v5.0.0
|
||||
with:
|
||||
images: ghcr.io/openimsdk/openim-server
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
|
||||
43
.github/workflows/build-openim-web-image.yml
vendored
43
.github/workflows/build-openim-web-image.yml
vendored
@ -114,15 +114,12 @@ jobs:
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
# ghcr.io/openimsdk/openim-web:latest
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta2
|
||||
uses: docker/metadata-action@v5.0.0
|
||||
with:
|
||||
install: true
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
images: ghcr.io/openimsdk/openim-web
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
@ -131,38 +128,12 @@ jobs:
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker openim-web
|
||||
id: meta1
|
||||
uses: docker/metadata-action@v5.0.0
|
||||
with:
|
||||
images: ghcr.io/openimsdk/openim-web
|
||||
|
||||
- name: Build and push Docker image for openim-web
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./build/images/openim-tools/openim-web/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta1.outputs.tags }}
|
||||
labels: ${{ steps.meta1.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker openim-web
|
||||
id: meta2
|
||||
uses: docker/metadata-action@v5.0.0
|
||||
with:
|
||||
images: ghcr.io/openimsdk/component
|
||||
|
||||
- name: Build and push Docker image for component
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./build/images/openim-tools/component/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta2.outputs.tags }}
|
||||
labels: ${{ steps.meta2.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
labels: ${{ steps.meta2.outputs.labels }}
|
||||
@ -126,7 +126,7 @@ It is recommended to use Docker Compose for deployment, which can easily and qui
|
||||
<details> <summary>Compile from Source</summary>
|
||||
|
||||
|
||||
Ur need `Go 1.18` or higher version, and `make`.
|
||||
Ur need `Go 1.20` or higher version, and `make`.
|
||||
|
||||
|
||||
```bash
|
||||
|
||||
10
build/images/Dockerfile
Normal file
10
build/images/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM BASE_IMAGE
|
||||
|
||||
WORKDIR ${SERVER_WORKDIR}
|
||||
|
||||
# Set HTTP proxy
|
||||
ARG BINARY_NAME
|
||||
|
||||
COPY BINARY_NAME ./bin/BINARY_NAME
|
||||
|
||||
ENTRYPOINT ["./bin/BINARY_NAME"]
|
||||
@ -103,6 +103,16 @@ $ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bas
|
||||
$ helm repo add brigade https://openimsdk.github.io/openim-charts
|
||||
```
|
||||
|
||||
### OpenIM 的镜像策略
|
||||
|
||||
自动化提供的 aliyun, ghcr, docker hub: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md
|
||||
|
||||
**本地化测试构建方法:**
|
||||
|
||||
```bash
|
||||
$ make image
|
||||
```
|
||||
|
||||
|
||||
### 容器化安装
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ REPO="Open-IM-Server"
|
||||
|
||||
# Version of Go you want to use, make sure it is compatible with your OpenIM-Server requirements.
|
||||
# Default is 1.18, if you want to use a different version, replace accordingly.
|
||||
GO_VERSION="1.18"
|
||||
GO_VERSION="1.20"
|
||||
|
||||
# Default HTTP_PORT is 80. If you want to use a different port, uncomment and replace the value.
|
||||
# HTTP_PORT=80
|
||||
@ -168,7 +168,7 @@ function install_go() {
|
||||
command -v go >/dev/null 2>&1
|
||||
# Determines if GO_VERSION is defined
|
||||
if [ -z "$GO_VERSION" ]; then
|
||||
GO_VERSION="1.18"
|
||||
GO_VERSION="1.20"
|
||||
fi
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
@ -309,7 +309,7 @@ function cmd_help() {
|
||||
color_echo ${BLUE_PREFIX} "-t, --tag ${CYAN_PREFIX}specify the tag (default option, set to latest if not specified)${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "-r, --release ${CYAN_PREFIX}specify the release branch (cannot be used with the tag option)${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "-gt, --github-token ${CYAN_PREFIX}set the GITHUB_TOKEN (default: not set)${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "-g, --go-version ${CYAN_PREFIX}set the Go language version (default: GO_VERSION=\"1.18\")${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "-g, --go-version ${CYAN_PREFIX}set the Go language version (default: GO_VERSION=\"1.20\")${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "--install-dir ${CYAN_PREFIX}set the OpenIM installation directory (default: /tmp)${COLOR_SUFFIX}"
|
||||
color_echo ${BLUE_PREFIX} "--cpu ${CYAN_PREFIX}set the number of concurrent processes${COLOR_SUFFIX}"
|
||||
echo
|
||||
@ -329,7 +329,7 @@ function parseinput() {
|
||||
# CHINA=false
|
||||
# TAG=latest
|
||||
# RELEASE=""
|
||||
# GO_VERSION=1.18
|
||||
# GO_VERSION=1.20
|
||||
# INSTALL_DIR=/tmp
|
||||
# GITHUB_TOKEN=""
|
||||
# CPU=$(nproc)
|
||||
|
||||
@ -167,6 +167,7 @@ define MAKEFILE_EXAMPLE
|
||||
# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing.
|
||||
# make build BINS=openim-api V=1 DEBUG=1 Build debug binaries for only openim-api.
|
||||
# make multiarch -j PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
|
||||
# make image
|
||||
endef
|
||||
export MAKEFILE_EXAMPLE
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ endif
|
||||
|
||||
# Determine image files by looking into build/images/*/Dockerfile
|
||||
IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/images/*)
|
||||
# Determine images names by stripping out the dir names
|
||||
IMAGES ?= $(filter-out tools,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
|
||||
# Determine images names by stripping out the dir names, and filter out the undesired directories
|
||||
IMAGES ?= $(filter-out Dockerfile openim-tools openim-cmdutils,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
|
||||
|
||||
ifeq (${IMAGES},)
|
||||
$(error Could not determine IMAGES, set ROOT_DIR or run in source dir)
|
||||
@ -100,10 +100,9 @@ image.build.%: go.build.%
|
||||
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
|
||||
@echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)"
|
||||
@mkdir -p $(TMP_DIR)/$(IMAGE)/$(PLATFORM)
|
||||
@awk '/FROM/ {c++; if (c==2) {print; next}} c>=2' $(ROOT_DIR)/build/images/$(IMAGE)/Dockerfile \
|
||||
| sed -e "s#BASE_IMAGE#$(BASE_IMAGE)#g" \
|
||||
-e 's/--from=builder //g' \
|
||||
-e 's#COPY /openim/openim-server/#COPY ./#g' > $(TMP_DIR)/$(IMAGE)/Dockerfile
|
||||
@cat $(ROOT_DIR)/build/images/Dockerfile\
|
||||
| sed "s#BASE_IMAGE#$(BASE_IMAGE)#g" \
|
||||
| sed "s#BINARY_NAME#$(IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile
|
||||
@cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)
|
||||
$(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
|
||||
@if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user