From 485bbb5b3cb659dd4d41c140406565f440a7caae Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:15:21 +0800 Subject: [PATCH] refactor(ci): actions and dockerfile (#3733) * feat(build): add unified server image build flow Consolidate service image definitions into a single server build setup, and update CI workflows to use it. # Conflicts: # .github/workflows/docker-build-and-release-services-images.yml # .github/workflows/go-build-test.yml # Dockerfile # build/images/Dockerfile # build/images/openim-api/Dockerfile # build/images/openim-crontask/Dockerfile # build/images/openim-msggateway/Dockerfile # build/images/openim-msgtransfer/Dockerfile # build/images/openim-push/Dockerfile # build/images/openim-rpc-auth/Dockerfile # build/images/openim-rpc-conversation/Dockerfile # build/images/openim-rpc-friend/Dockerfile # build/images/openim-rpc-group/Dockerfile # build/images/openim-rpc-msg/Dockerfile # build/images/openim-rpc-third/Dockerfile # build/images/openim-rpc-user/Dockerfile # build/images/openim-tools/component/Dockerfile * fix(ci): correct Docker image tag generation --- ...cker-build-and-release-services-images.yml | 117 +++++++++------ .github/workflows/go-build-test.yml | 138 ++++++++++++++---- Dockerfile | 54 ++----- build/build.sh | 133 +++++++++++++++++ build/images/Dockerfile | 24 --- build/images/openim-api/Dockerfile | 44 ------ build/images/openim-cmdutils/Dockerfile | 44 ------ build/images/openim-crontask/Dockerfile | 44 ------ build/images/openim-msggateway/Dockerfile | 44 ------ build/images/openim-msgtransfer/Dockerfile | 44 ------ build/images/openim-push/Dockerfile | 44 ------ build/images/openim-rpc-auth/Dockerfile | 44 ------ .../images/openim-rpc-conversation/Dockerfile | 44 ------ build/images/openim-rpc-friend/Dockerfile | 44 ------ build/images/openim-rpc-group/Dockerfile | 44 ------ build/images/openim-rpc-msg/Dockerfile | 44 ------ build/images/openim-rpc-third/Dockerfile | 44 ------ build/images/openim-rpc-user/Dockerfile | 44 ------ build/images/openim-server/Dockerfile | 30 ++++ .../docker-compose.build.override.yml | 72 +++++++++ .../openim-server/docker-compose.build.yml | 120 +++++++++++++++ .../images/openim-tools/component/Dockerfile | 48 ------ 22 files changed, 549 insertions(+), 759 deletions(-) create mode 100755 build/build.sh delete mode 100644 build/images/Dockerfile delete mode 100644 build/images/openim-api/Dockerfile delete mode 100644 build/images/openim-cmdutils/Dockerfile delete mode 100644 build/images/openim-crontask/Dockerfile delete mode 100644 build/images/openim-msggateway/Dockerfile delete mode 100644 build/images/openim-msgtransfer/Dockerfile delete mode 100644 build/images/openim-push/Dockerfile delete mode 100644 build/images/openim-rpc-auth/Dockerfile delete mode 100644 build/images/openim-rpc-conversation/Dockerfile delete mode 100644 build/images/openim-rpc-friend/Dockerfile delete mode 100644 build/images/openim-rpc-group/Dockerfile delete mode 100644 build/images/openim-rpc-msg/Dockerfile delete mode 100644 build/images/openim-rpc-third/Dockerfile delete mode 100644 build/images/openim-rpc-user/Dockerfile create mode 100644 build/images/openim-server/Dockerfile create mode 100644 build/images/openim-server/docker-compose.build.override.yml create mode 100644 build/images/openim-server/docker-compose.build.yml delete mode 100644 build/images/openim-tools/component/Dockerfile diff --git a/.github/workflows/docker-build-and-release-services-images.yml b/.github/workflows/docker-build-and-release-services-images.yml index d156e2409..1d085e153 100644 --- a/.github/workflows/docker-build-and-release-services-images.yml +++ b/.github/workflows/docker-build-and-release-services-images.yml @@ -1,4 +1,4 @@ -name: Build and release services Images +name: Build and release services Docker Images on: push: @@ -16,76 +16,97 @@ on: jobs: build-and-push: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.3.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3.8.0 - name: Log in to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3.3.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3.3.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Aliyun Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3.3.0 with: registry: registry.cn-hangzhou.aliyuncs.com username: ${{ secrets.ALIREGISTRY_USERNAME }} password: ${{ secrets.ALIREGISTRY_TOKEN }} - - name: Extract metadata for Docker (tags, labels) - id: meta - uses: docker/metadata-action@v5 - with: - tags: | - type=ref,event=tag - type=schedule - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern=v{{version}} - # type=semver,pattern={{major}}.{{minor}} - type=semver,pattern=release-{{raw}} - type=sha - type=raw,value=${{ github.event.inputs.tag }} + - name: Resolve Docker image tags + id: tags + env: + INPUT_TAG: ${{ github.event.inputs.tag }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + set -euo pipefail + + tags=() + declare -A seen=() + + add_tag() { + local tag="$1" + [[ -n "$tag" ]] || return 0 + + tag="${tag//\//-}" + if [[ -z "${seen[$tag]+x}" ]]; then + tags+=("$tag") + seen["$tag"]=1 + fi + } + + add_tag_with_semver_alias() { + local tag="$1" + add_tag "$tag" + if [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then + add_tag "${BASH_REMATCH[1]}" + add_tag "release-$tag" + fi + } + + add_tag_with_semver_alias "${INPUT_TAG:-}" + add_tag_with_semver_alias "${RELEASE_TAG:-}" + + if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then + add_tag_with_semver_alias "${GITHUB_REF_NAME}" + elif [[ "${GITHUB_REF_TYPE:-}" == "branch" ]]; then + add_tag "${GITHUB_REF_NAME}" + fi + + add_tag "sha-${GITHUB_SHA::7}" + + { + echo "tags<> "$GITHUB_OUTPUT" - name: Build and push Docker images + env: + RELEASE: "true" + PUSH: "true" + PLATFORMS: linux/amd64,linux/arm64 + IMAGE_TAGS: ${{ steps.tags.outputs.tags }} + IMAGE_REGISTRIES: | + ${{ secrets.DOCKER_USERNAME }} + ghcr.io/${{ github.repository_owner }} + registry.cn-hangzhou.aliyuncs.com/openimsdk run: | - ROOT_DIR="build/images" - for dir in "$ROOT_DIR"/*/; do - # Find Dockerfile or *.dockerfile in a case-insensitive manner - dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1) - - if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then - IMAGE_NAME=$(basename "$dir") - echo "Building Docker image for $IMAGE_NAME with tags:" - - # Initialize tag arguments - tag_args=() - - # Read each tag and append --tag arguments - while IFS= read -r tag; do - tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag") - tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag") - tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag") - done <<< "${{ steps.meta.outputs.tags }}" - - # Build and push the Docker image with all tags - docker buildx build --platform linux/amd64,linux/arm64 \ - --file "$dockerfile" \ - "${tag_args[@]}" \ - --push "$dir" - else - echo "No valid Dockerfile found in $dir" - fi - done + bash build/build.sh diff --git a/.github/workflows/go-build-test.yml b/.github/workflows/go-build-test.yml index 60b64d118..8425293e9 100644 --- a/.github/workflows/go-build-test.yml +++ b/.github/workflows/go-build-test.yml @@ -4,7 +4,7 @@ on: push: pull_request: paths-ignore: - - '**/*.md' + - "**/*.md" workflow_dispatch: @@ -12,13 +12,17 @@ jobs: go-build: name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} + + env: + SHARE_CONFIG_PATH: config/share.yml + permissions: contents: write pull-requests: write strategy: matrix: os: [ubuntu-latest] - go_version: ["1.21.x", "1.22.x"] + go_version: ["1.25.x"] steps: - name: Checkout Server repository @@ -37,27 +41,24 @@ jobs: - name: Set up infra services uses: hoverkraft-tech/compose-action@v2.0.1 - # Uncomment and set the correct path to your docker-compose file with: compose-file: "./docker-compose.yml" - # run: | - # sudo docker compose up -d - # sudo sleep 30 # Increased sleep time for better stability - # timeout-minutes: 60 # Increased timeout for Docker setup + - name: Modify Server Configuration + run: | + yq e '.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }} + # - name: Get Internal IP Address + # id: get-ip + # run: | + # IP=$(hostname -I | awk '{print $1}') + # echo "The IP Address is: $IP" + # echo "::set-output name=ip::$IP" - # - name: Get Internal IP Address - # id: get-ip - # run: | - # IP=$(hostname -I | awk '{print $1}') - # echo "The IP Address is: $IP" - # echo "::set-output name=ip::$IP" - - # - name: Update .env - # run: | - # sed -i 's|externalAddress:.*|externalAddress: "http://${{ steps.get-ip.outputs.ip }}:10005"|' config/minio.yml - # cat config/minio.yml + # - name: Update .env + # run: | + # sed -i 's|externalAddress:.*|externalAddress: "http://${{ steps.get-ip.outputs.ip }}:10005"|' config/minio.yml + # cat config/minio.yml - name: Build and test Server Services run: | @@ -78,6 +79,11 @@ jobs: go mod download go install github.com/magefile/mage@latest + - name: Modify Chat Configuration + run: | + cd ${{ github.workspace }}/chat-repo + yq e '.openIM.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }} + - name: Build and test Chat Services run: | cd ${{ github.workspace }}/chat-repo @@ -85,6 +91,90 @@ jobs: mage start mage check + - name: Test Server and Chat + run: | + check_error() { + echo "Response: $1" + errCode=$(echo $1 | jq -r '.errCode') + if [ "$errCode" != "0" ]; then + errMsg=$(echo $1 | jq -r '.errMsg') + echo "Error: $errMsg" + exit 1 + fi + } + + # Test register + response1=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{ + "verifyCode": "666666", + "platform": 3, + "autoLogin": true, + "user":{ + "nickname": "test12312", + "areaCode":"+86", + "phoneNumber": "12345678190", + "password":"test123456" + } + }' http://127.0.0.1:10008/account/register) + check_error "$response1" + userID1=$(echo $response1 | jq -r '.data.userID') + echo "userID1: $userID1" + + response2=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{ + "verifyCode": "666666", + "platform": 3, + "autoLogin": true, + "user":{ + "nickname": "test22312", + "areaCode":"+86", + "phoneNumber": "12345678290", + "password":"test123456" + } + }' http://127.0.0.1:10008/account/register) + check_error "$response2" + userID2=$(echo $response2 | jq -r '.data.userID') + echo "userID2: $userID2" + + # Test login + login_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{ + "platform": 3, + "areaCode":"+86", + "phoneNumber": "12345678190", + "password":"test123456" + }' http://localhost:10008/account/login) + check_error "$login_response" + + # Test get admin token + get_admin_token_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{ + "secret": "123456", + "platformID": 2, + "userID": "imAdmin" + }' http://127.0.0.1:10002/auth/get_admin_token) + check_error "$get_admin_token_response" + adminToken=$(echo $get_admin_token_response | jq -r '.data.token') + echo "adminToken: $adminToken" + + # Test send message + send_msg_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -H "token: $adminToken" -d '{ + "sendID": "'$userID1'", + "recvID": "'$userID2'", + "senderPlatformID": 3, + "content": { + "content": "hello!!" + }, + "contentType": 101, + "sessionType": 1 + }' http://127.0.0.1:10002/msg/send_msg) + check_error "$send_msg_response" + + # Test get users + get_users_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -H "token: $adminToken" -d '{ + "pagination": { + "pageNumber": 1, + "showNumber": 100 + } + }' http://127.0.0.1:10002/user/get_users) + check_error "$get_users_response" + go-test: name: Benchmark Test with go ${{ matrix.go_version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -98,7 +188,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go_version: ["1.22.x"] + go_version: ["1.25.x"] steps: - name: Checkout Server repository @@ -147,7 +237,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: ["1.22"] + go_version: ["1.25.x"] steps: - name: Checkout Repository @@ -181,11 +271,3 @@ jobs: run: | CONTAINER_NAME="${{ github.event.repository.name }}-container" docker logs $CONTAINER_NAME - - # - name: Cleanup Docker Container - # run: | - # CONTAINER_NAME="${{ github.event.repository.name }}-container" - # IMAGE_NAME="${{ github.event.repository.name }}-test" - # docker stop $CONTAINER_NAME - # docker rm $CONTAINER_NAME - # docker rmi $IMAGE_NAME diff --git a/Dockerfile b/Dockerfile index ca9192b61..30af8f7ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,25 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder +FROM golang:1.25-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server +ARG RELEASE=false +ARG COMPRESS=false +WORKDIR /openim-server -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR +RUN apk add --no-cache upx -# Set the Go proxy to improve dependency resolution speed -# ENV GOPROXY=https://goproxy.io,direct +RUN go install github.com/magefile/mage@latest -# Copy all files from the current directory into the container COPY . . - RUN go mod download +RUN RELEASE=${RELEASE} COMPRESS=${COMPRESS} mage build +RUN mage -compile ./mage -ldflags "-s -w" -# Install Mage to use for building the application -RUN go install github.com/magefile/mage@v1.15.0 +FROM alpine:latest -# Optionally build your application if needed -RUN mage build +WORKDIR /openim-server -# Using Alpine Linux with Go environment for the final image -FROM golang:1.22-alpine +COPY --from=builder /openim-server/_output ./_output +COPY --from=builder /openim-server/config ./config +COPY --from=builder /openim-server/start-config.yml ./start-config.yml +COPY --from=builder /openim-server/mage ./mage -# 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 -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 go get github.com/openimsdk/gomake@v0.0.15-alpha.5 - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"] +ENTRYPOINT ["sh", "-c", "./mage start && sleep infinity"] \ No newline at end of file diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 000000000..354cd3945 --- /dev/null +++ b/build/build.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CYAN='\033[0;36m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NO_COLOR='\033[0m' + +BASE_DIR="$(cd "$(dirname "$0")" && pwd)" +COMPOSE_FILE="$BASE_DIR/images/openim-server/docker-compose.build.yml" +RELEASE="${RELEASE:-false}" +PUSH="${PUSH:-false}" +DRY_RUN="${DRY_RUN:-false}" +PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}" +IMAGE_TAGS="${IMAGE_TAGS:-}" +IMAGE_REGISTRIES="${IMAGE_REGISTRIES:-}" + +if [[ ! -f "$COMPOSE_FILE" ]]; then + echo -e "${RED}docker-compose.build.yml not found: $COMPOSE_FILE${NO_COLOR}" + exit 1 +fi + +cd "$BASE_DIR/.." || exit 1 + +split_values() { + printf '%s\n' "$1" | tr ', ' '\n\n' | while IFS= read -r value; do + [[ -n "$value" ]] && printf '%s\n' "$value" + done +} + +print_command() { + printf '%q ' "$@" + printf '\n' +} + +run_or_print() { + if [[ "$DRY_RUN" == "true" ]]; then + print_command "$@" + else + "$@" + fi +} + +build_local() { + echo -e "${CYAN}Building all services...${NO_COLOR}" + RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build + + echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}" + while IFS= read -r built_image; do + [[ -n "$built_image" ]] || continue + compatibility_tag="${built_image##*/}" + + if [[ "$built_image" != "$compatibility_tag" ]]; then + docker tag "$built_image" "$compatibility_tag" + fi + done < <(docker compose -f "$COMPOSE_FILE" config --images) + + echo -e "${GREEN}Successfully built all services${NO_COLOR}" +} + +build_push() { + if ! command -v jq >/dev/null 2>&1; then + echo -e "${RED}jq is required for PUSH=true${NO_COLOR}" + exit 1 + fi + + if [[ -z "$IMAGE_TAGS" || -z "$IMAGE_REGISTRIES" ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES are required for PUSH=true${NO_COLOR}" + exit 1 + fi + + image_tags=() + while IFS= read -r tag; do + image_tags+=("$tag") + done < <(split_values "$IMAGE_TAGS") + + image_registries=() + while IFS= read -r registry; do + image_registries+=("$registry") + done < <(split_values "$IMAGE_REGISTRIES") + + if [[ ${#image_tags[@]} -eq 0 || ${#image_registries[@]} -eq 0 ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES must contain at least one value${NO_COLOR}" + exit 1 + fi + + compose_config=$(docker compose -f "$COMPOSE_FILE" config --format json) + + echo -e "${CYAN}Building and pushing service images...${NO_COLOR}" + while IFS= read -r service; do + context=$(jq -r --arg service "$service" '.services[$service].build.context // empty' <<< "$compose_config") + dockerfile=$(jq -r --arg service "$service" '.services[$service].build.dockerfile // empty' <<< "$compose_config") + cmd_path=$(jq -r --arg service "$service" '.services[$service].build.args.CMD_PATH // empty' <<< "$compose_config") + binary_name=$(jq -r --arg service "$service" '.services[$service].build.args.BINARY_NAME // empty' <<< "$compose_config") + + if [[ -z "$context" || -z "$dockerfile" || -z "$cmd_path" || -z "$binary_name" ]]; then + echo -e "${RED}Invalid build config for $service${NO_COLOR}" + exit 1 + fi + + if [[ ! -d "$cmd_path" && ! -f "$cmd_path/main.go" ]]; then + echo -e "${CYAN}Skipping $service because $cmd_path does not exist${NO_COLOR}" + continue + fi + + tag_args=() + for registry in "${image_registries[@]}"; do + for tag in "${image_tags[@]}"; do + tag_args+=(--tag "$registry/$binary_name:$tag") + done + done + + echo -e "${CYAN}Building $binary_name for $PLATFORMS...${NO_COLOR}" + run_or_print docker buildx build \ + --platform "$PLATFORMS" \ + --file "$dockerfile" \ + --build-arg "CMD_PATH=$cmd_path" \ + --build-arg "BINARY_NAME=$binary_name" \ + --build-arg "RELEASE=$RELEASE" \ + "${tag_args[@]}" \ + --push \ + "$context" + done < <(jq -r '.services | keys[]' <<< "$compose_config" | sort) + + echo -e "${GREEN}Successfully pushed service images${NO_COLOR}" +} + +if [[ "$PUSH" == "true" ]]; then + build_push +else + build_local +fi diff --git a/build/images/Dockerfile b/build/images/Dockerfile deleted file mode 100644 index 51fe94e1c..000000000 --- a/build/images/Dockerfile +++ /dev/null @@ -1,24 +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. - -FROM BASE_IMAGE - -WORKDIR ${SERVER_WORKDIR} - -# Set HTTP proxy -ARG BINARY_NAME - -COPY BINARY_NAME ./bin/BINARY_NAME - -ENTRYPOINT ["./bin/BINARY_NAME"] \ No newline at end of file diff --git a/build/images/openim-api/Dockerfile b/build/images/openim-api/Dockerfile deleted file mode 100644 index 662223956..000000000 --- a/build/images/openim-api/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-api - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-api /usr/bin/openim-api - -# 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 /usr/bin/openim-api ./bin/openim-api - -ENTRYPOINT ["./bin/openim-api"] diff --git a/build/images/openim-cmdutils/Dockerfile b/build/images/openim-cmdutils/Dockerfile deleted file mode 100644 index 34bcd41f5..000000000 --- a/build/images/openim-cmdutils/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-cmdutils -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-cmdutils /usr/bin/openim-cmdutils - -FROM ghcr.io/openim-sigs/openim-bash-image:latest - -WORKDIR /openim/openim-server - -COPY --from=builder /usr/bin/openim-cmdutils ./bin/openim-cmdutils - -ENTRYPOINT ["./bin/openim-cmdutils"] - -CMD ["--help"] diff --git a/build/images/openim-crontask/Dockerfile b/build/images/openim-crontask/Dockerfile deleted file mode 100644 index 90a562926..000000000 --- a/build/images/openim-crontask/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-crontask - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-crontask /usr/bin/openim-crontask - -# 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 /usr/bin/openim-crontask ./bin/openim-crontask - -ENTRYPOINT ["./bin/openim-crontask"] diff --git a/build/images/openim-msggateway/Dockerfile b/build/images/openim-msggateway/Dockerfile deleted file mode 100644 index d3a8694ed..000000000 --- a/build/images/openim-msggateway/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-msggateway - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-msggateway /usr/bin/openim-msggateway - -# 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 /usr/bin/openim-msggateway ./bin/openim-msggateway - -ENTRYPOINT ["./bin/openim-msggateway"] diff --git a/build/images/openim-msgtransfer/Dockerfile b/build/images/openim-msgtransfer/Dockerfile deleted file mode 100644 index f94978648..000000000 --- a/build/images/openim-msgtransfer/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-msgtransfer - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-msgtransfer /usr/bin/openim-msgtransfer - -# 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 /usr/bin/openim-msgtransfer ./bin/openim-msgtransfer - -ENTRYPOINT ["./bin/openim-msgtransfer"] diff --git a/build/images/openim-push/Dockerfile b/build/images/openim-push/Dockerfile deleted file mode 100644 index faebbe9c0..000000000 --- a/build/images/openim-push/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-push - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-push /usr/bin/openim-push - -# 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 /usr/bin/openim-push ./bin/openim-push - -ENTRYPOINT ["./bin/openim-push"] diff --git a/build/images/openim-rpc-auth/Dockerfile b/build/images/openim-rpc-auth/Dockerfile deleted file mode 100644 index 1e905d4b2..000000000 --- a/build/images/openim-rpc-auth/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-auth - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth /usr/bin/openim-rpc-auth - -# 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 /usr/bin/openim-rpc-auth ./bin/openim-rpc-auth - -ENTRYPOINT ["./bin/openim-rpc-auth"] diff --git a/build/images/openim-rpc-conversation/Dockerfile b/build/images/openim-rpc-conversation/Dockerfile deleted file mode 100644 index 5a69aa89f..000000000 --- a/build/images/openim-rpc-conversation/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-conversation - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation /usr/bin/openim-rpc-conversation - -# 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 /usr/bin/openim-rpc-conversation ./bin/openim-rpc-conversation - -ENTRYPOINT ["./bin/openim-rpc-conversation"] diff --git a/build/images/openim-rpc-friend/Dockerfile b/build/images/openim-rpc-friend/Dockerfile deleted file mode 100644 index fad21a880..000000000 --- a/build/images/openim-rpc-friend/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-friend - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-friend /usr/bin/openim-rpc-friend - -# 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 /usr/bin/openim-rpc-friend ./bin/openim-rpc-friend - -ENTRYPOINT ["./bin/openim-rpc-friend"] diff --git a/build/images/openim-rpc-group/Dockerfile b/build/images/openim-rpc-group/Dockerfile deleted file mode 100644 index d7dede6b9..000000000 --- a/build/images/openim-rpc-group/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-group - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-group /usr/bin/openim-rpc-group - -# 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 /usr/bin/openim-rpc-group ./bin/openim-rpc-group - -ENTRYPOINT ["./bin/openim-rpc-group"] diff --git a/build/images/openim-rpc-msg/Dockerfile b/build/images/openim-rpc-msg/Dockerfile deleted file mode 100644 index 71ad85f37..000000000 --- a/build/images/openim-rpc-msg/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-msg - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-msg /usr/bin/openim-rpc-msg - -# 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 /usr/bin/openim-rpc-msg ./bin/openim-rpc-msg - -ENTRYPOINT ["./bin/openim-rpc-msg"] diff --git a/build/images/openim-rpc-third/Dockerfile b/build/images/openim-rpc-third/Dockerfile deleted file mode 100644 index 3560ad0d7..000000000 --- a/build/images/openim-rpc-third/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-third - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-third /usr/bin/openim-rpc-third - -# 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 /usr/bin/openim-rpc-third ./bin/openim-rpc-third - -ENTRYPOINT ["./bin/openim-rpc-third"] diff --git a/build/images/openim-rpc-user/Dockerfile b/build/images/openim-rpc-user/Dockerfile deleted file mode 100644 index a9891ece8..000000000 --- a/build/images/openim-rpc-user/Dockerfile +++ /dev/null @@ -1,44 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -ENV GOPROXY=$GOPROXY - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN make build BINS=openim-rpc-user - -RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user /usr/bin/openim-rpc-user - -# 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 /usr/bin/openim-rpc-user ./bin/openim-rpc-user - -ENTRYPOINT ["./bin/openim-rpc-user"] diff --git a/build/images/openim-server/Dockerfile b/build/images/openim-server/Dockerfile new file mode 100644 index 000000000..e821260a6 --- /dev/null +++ b/build/images/openim-server/Dockerfile @@ -0,0 +1,30 @@ +FROM golang:1.25-alpine AS builder + +ARG CMD_PATH +ARG BINARY_NAME +ARG RELEASE=false + +ENV SERVER_DIR=/openim-server +WORKDIR $SERVER_DIR + +COPY . . +RUN go mod tidy + +RUN if [ "$RELEASE" = "true" ]; then \ + go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \ + else \ + go build -o _output/${BINARY_NAME} ./${CMD_PATH}; \ + fi + +FROM alpine:latest + +RUN apk add --no-cache bash + +ARG BINARY_NAME +ENV BINARY_NAME=${BINARY_NAME} +ENV SERVER_DIR=/openim-server +WORKDIR $SERVER_DIR + +COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output + +ENTRYPOINT ["sh", "-c", "_output/${BINARY_NAME}"] \ No newline at end of file diff --git a/build/images/openim-server/docker-compose.build.override.yml b/build/images/openim-server/docker-compose.build.override.yml new file mode 100644 index 000000000..7ef19f988 --- /dev/null +++ b/build/images/openim-server/docker-compose.build.override.yml @@ -0,0 +1,72 @@ +services: + openim-api: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-crontask: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-msggateway: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-msgtransfer: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-push: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-auth: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-conversation: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-friend: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-group: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-msg: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-third: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-user: + build: + platforms: + - linux/amd64 + - linux/arm64 diff --git a/build/images/openim-server/docker-compose.build.yml b/build/images/openim-server/docker-compose.build.yml new file mode 100644 index 000000000..1837fa836 --- /dev/null +++ b/build/images/openim-server/docker-compose.build.yml @@ -0,0 +1,120 @@ +services: + openim-api: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-api + BINARY_NAME: openim-api + RELEASE: ${RELEASE:-false} + image: openim-api:test + + openim-crontask: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-crontask + BINARY_NAME: openim-crontask + RELEASE: ${RELEASE:-false} + image: openim-crontask:test + + openim-msggateway: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-msggateway + BINARY_NAME: openim-msggateway + RELEASE: ${RELEASE:-false} + image: openim-msggateway:test + + openim-msgtransfer: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-msgtransfer + BINARY_NAME: openim-msgtransfer + RELEASE: ${RELEASE:-false} + image: openim-msgtransfer:test + + openim-push: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-push + BINARY_NAME: openim-push + RELEASE: ${RELEASE:-false} + image: openim-push:test + + openim-rpc-auth: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-auth + BINARY_NAME: openim-rpc-auth + RELEASE: ${RELEASE:-false} + image: openim-rpc-auth:test + + openim-rpc-conversation: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-conversation + BINARY_NAME: openim-rpc-conversation + RELEASE: ${RELEASE:-false} + image: openim-rpc-conversation:test + + openim-rpc-friend: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-friend + BINARY_NAME: openim-rpc-friend + RELEASE: ${RELEASE:-false} + image: openim-rpc-friend:test + + openim-rpc-group: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-group + BINARY_NAME: openim-rpc-group + RELEASE: ${RELEASE:-false} + image: openim-rpc-group:test + + openim-rpc-msg: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-msg + BINARY_NAME: openim-rpc-msg + RELEASE: ${RELEASE:-false} + image: openim-rpc-msg:test + + openim-rpc-third: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-third + BINARY_NAME: openim-rpc-third + RELEASE: ${RELEASE:-false} + image: openim-rpc-third:test + + openim-rpc-user: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-user + BINARY_NAME: openim-rpc-user + RELEASE: ${RELEASE:-false} + image: openim-rpc-user:test diff --git a/build/images/openim-tools/component/Dockerfile b/build/images/openim-tools/component/Dockerfile deleted file mode 100644 index 6bdfa6942..000000000 --- a/build/images/openim-tools/component/Dockerfile +++ /dev/null @@ -1,48 +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. - -# OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# Set go mod installation source and proxy - -FROM golang:1.20 AS builder - -ARG GO111MODULE=on - -WORKDIR /openim/openim-server - -ENV GO111MODULE=$GO111MODULE -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"]