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 generationpull/3705/head
parent
4cb05243df
commit
485bbb5b3c
@ -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
|
||||
|
||||
# Optionally build your application if needed
|
||||
RUN mage build
|
||||
|
||||
# Using Alpine Linux with Go environment for the final image
|
||||
FROM golang:1.22-alpine
|
||||
|
||||
# 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
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
# 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/
|
||||
WORKDIR /openim-server
|
||||
|
||||
RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.5
|
||||
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
|
||||
|
||||
# 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"]
|
||||
@ -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
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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"]
|
||||
@ -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}"]
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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"]
|
||||
Loading…
Reference in new issue