- move Python sources into app package and switch services to module entrypoints - relocate Dockerfiles under docker/, add buildx publish script, override compose for local builds - configure images to pull from gitea.04080616.xyz/yiekheng with env-driven tags and limits - harden installs and transfer worker logging/concurrency for cleaner container output
84 lines
2.1 KiB
Bash
Executable File
84 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REGISTRY_PREFIX="gitea.04080616.xyz/yiekheng"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Build and push CM Bot service images to gitea.04080616.xyz/yiekheng.
|
|
|
|
Usage:
|
|
scripts/publish.sh [tag]
|
|
|
|
Arguments:
|
|
tag Optional tag to publish (default: latest). Override with DOCKER_IMAGE_TAG.
|
|
|
|
Environment:
|
|
DOCKER_IMAGE_TAG Alternative way to set the tag (overrides CLI argument).
|
|
BUILD_ARGS Extra arguments passed to each docker build command.
|
|
|
|
Make sure you are authenticated first:
|
|
docker login gitea.04080616.xyz
|
|
EOF
|
|
}
|
|
|
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
if ! docker info >/dev/null 2>&1; then
|
|
echo "Docker daemon is not reachable. Please start Docker and retry." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! docker system info --format '{{json .IndexServerAddress}}' | grep -q "gitea.04080616.xyz" 2>/dev/null; then
|
|
cat <<'EOF' >&2
|
|
Reminder: run 'docker login gitea.04080616.xyz' before publishing so pushes succeed.
|
|
EOF
|
|
fi
|
|
|
|
IMAGE_TAG="${1:-${DOCKER_IMAGE_TAG:-latest}}"
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PLATFORMS="${CM_IMAGE_PLATFORMS:-linux/amd64}"
|
|
|
|
if ! docker buildx version >/dev/null 2>&1; then
|
|
cat <<'EOF' >&2
|
|
Docker Buildx is required for producing registry-compatible images.
|
|
Install/enable buildx and rerun, for example:
|
|
docker buildx create --use --name cm-bot-builder
|
|
docker buildx inspect --bootstrap
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
echo "Using buildx with platforms: ${PLATFORMS}"
|
|
echo
|
|
|
|
SERVICES=(
|
|
"api docker/api/Dockerfile"
|
|
"telegram docker/telegram/Dockerfile"
|
|
"web docker/web/Dockerfile"
|
|
"transfer docker/transfer/Dockerfile"
|
|
)
|
|
|
|
echo "Publishing CM Bot images to ${REGISTRY_PREFIX}/cm-<service>:${IMAGE_TAG}"
|
|
echo
|
|
|
|
for ENTRY in "${SERVICES[@]}"; do
|
|
SERVICE="${ENTRY%% *}"
|
|
DOCKERFILE="${ENTRY#* }"
|
|
IMAGE_NAME="${REGISTRY_PREFIX}/cm-${SERVICE}:${IMAGE_TAG}"
|
|
|
|
echo "==> Building and pushing ${IMAGE_NAME} (${DOCKERFILE})"
|
|
docker buildx build ${BUILD_ARGS:-} \
|
|
--platform "${PLATFORMS}" \
|
|
-f "${ROOT_DIR}/${DOCKERFILE}" \
|
|
-t "${IMAGE_NAME}" \
|
|
--push \
|
|
"${ROOT_DIR}"
|
|
echo
|
|
done
|
|
|
|
echo "All images pushed to ${REGISTRY_PREFIX} with tag '${IMAGE_TAG}'."
|