diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6db84fc2..82664c59 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,6 +24,7 @@ # - Only triggers when Linux builds (x86_64 + aarch64) are successful # - Independent of macOS/Windows build status # - Uses workflow_run event for precise control +# - Only builds Docker images for releases and prereleases (development builds are skipped) name: Docker Images @@ -47,9 +48,9 @@ on: default: true type: boolean version: - description: "Version to build (latest, main-latest, dev-latest, or specific version like v1.0.0 or dev-abc123)" + description: "Version to build (latest for stable release, or specific version like v1.0.0, v1.0.0-alpha1)" required: false - default: "main-latest" + default: "latest" type: string force_rebuild: description: "Force rebuild even if binary exists (useful for testing)" @@ -117,20 +118,28 @@ jobs: if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then build_type="development" version="dev-${short_sha}" + # Skip Docker build for development builds + should_build=false + echo "โญ๏ธ Skipping Docker build for development version (main branch)" elif [[ "${{ github.event.workflow_run.event }}" == "push" ]] && [[ "${{ github.event.workflow_run.head_branch }}" =~ ^refs/tags/ ]]; then - # Tag push + # Tag push - only build for releases and prereleases tag_name="${{ github.event.workflow_run.head_branch }}" version="${tag_name#refs/tags/}" if [[ "$version" == *"alpha"* ]] || [[ "$version" == *"beta"* ]] || [[ "$version" == *"rc"* ]]; then build_type="prerelease" is_prerelease=true + echo "๐Ÿงช Building Docker image for prerelease: $version" else build_type="release" create_latest=true + echo "๐Ÿš€ Building Docker image for release: $version" fi else build_type="development" version="dev-${short_sha}" + # Skip Docker build for development builds + should_build=false + echo "โญ๏ธ Skipping Docker build for development version" fi echo "๐Ÿ”„ Build triggered by workflow_run:" @@ -160,16 +169,6 @@ jobs: create_latest=true echo "๐Ÿš€ Building with latest stable release version" ;; - "main-latest") - build_type="development" - version="main-latest" - echo "๐Ÿ› ๏ธ Building with main branch latest development version" - ;; - "dev-latest") - build_type="development" - version="dev-latest" - echo "๐Ÿ› ๏ธ Building with development latest version" - ;; v[0-9]*) build_type="release" create_latest=true @@ -180,14 +179,11 @@ jobs: is_prerelease=true echo "๐Ÿงช Building with prerelease version: $input_version" ;; - dev-[a-f0-9]*) - build_type="development" - echo "๐Ÿ”ง Building with specific development version: $input_version" - ;; *) - build_type="development" - echo "๐Ÿ”ง Building with custom version: $input_version" - echo "โš ๏ธ Warning: Custom version format may not follow standard patterns" + # Invalid version for Docker build + should_build=false + echo "โŒ Invalid version for Docker build: $input_version" + echo "โš ๏ธ Only release versions (latest, v1.0.0) and prereleases (v1.0.0-alpha1) are supported" ;; esac fi @@ -252,28 +248,18 @@ jobs: # Convert version format for Dockerfile compatibility case "$VERSION" in - "main-latest"|"dev-latest") - # For latest builds, use RELEASE=latest + appropriate CHANNEL - DOCKER_RELEASE="latest" - DOCKER_CHANNEL="dev" - ;; "latest") # For stable latest, use RELEASE=latest + release CHANNEL DOCKER_RELEASE="latest" DOCKER_CHANNEL="release" ;; - dev-*) - # For development builds (dev-abc123), pass as-is without 'v' prefix - DOCKER_RELEASE="${VERSION}" - DOCKER_CHANNEL="dev" - ;; v*) # For versioned releases (v1.0.0), remove 'v' prefix for Dockerfile DOCKER_RELEASE="${VERSION#v}" DOCKER_CHANNEL="release" ;; *) - # For custom versions, pass as-is + # For other versions, pass as-is DOCKER_RELEASE="${VERSION}" DOCKER_CHANNEL="release" ;; @@ -288,33 +274,25 @@ jobs: echo " - Docker CHANNEL: $DOCKER_CHANNEL" # Generate tags based on build type - TAGS="" + # Only support release and prerelease builds (no development builds) + TAGS="${{ env.REGISTRY_DOCKERHUB }}:${VERSION}" - if [[ "$BUILD_TYPE" == "development" ]]; then - # Development build: dev-${short_sha} and dev - TAGS="${{ env.REGISTRY_DOCKERHUB }}:dev-${SHORT_SHA}" - TAGS="$TAGS,${{ env.REGISTRY_DOCKERHUB }}:dev" - else - # Release/Prerelease build: ${version} - TAGS="${{ env.REGISTRY_DOCKERHUB }}:${VERSION}" + # Add channel tags for prereleases and latest for stable + if [[ "$CREATE_LATEST" == "true" ]]; then + # Stable release + TAGS="$TAGS,${{ env.REGISTRY_DOCKERHUB }}:latest" + elif [[ "$BUILD_TYPE" == "prerelease" ]]; then + # Prerelease channel tags (alpha, beta, rc) + if [[ "$VERSION" == *"alpha"* ]]; then + CHANNEL="alpha" + elif [[ "$VERSION" == *"beta"* ]]; then + CHANNEL="beta" + elif [[ "$VERSION" == *"rc"* ]]; then + CHANNEL="rc" + fi - # Add channel tags for prereleases and latest for stable - if [[ "$CREATE_LATEST" == "true" ]]; then - # Stable release - TAGS="$TAGS,${{ env.REGISTRY_DOCKERHUB }}:latest" - elif [[ "$BUILD_TYPE" == "prerelease" ]]; then - # Prerelease channel tags (alpha, beta, rc) - if [[ "$VERSION" == *"alpha"* ]]; then - CHANNEL="alpha" - elif [[ "$VERSION" == *"beta"* ]]; then - CHANNEL="beta" - elif [[ "$VERSION" == *"rc"* ]]; then - CHANNEL="rc" - fi - - if [[ -n "$CHANNEL" ]]; then - TAGS="$TAGS,${{ env.REGISTRY_DOCKERHUB }}:${CHANNEL}" - fi + if [[ -n "$CHANNEL" ]]; then + TAGS="$TAGS,${{ env.REGISTRY_DOCKERHUB }}:${CHANNEL}" fi fi @@ -384,14 +362,10 @@ jobs: echo "๐Ÿณ Docker build completed successfully!" echo "๐Ÿ“ฆ Build type: $BUILD_TYPE" echo "๐Ÿ”ข Version: $VERSION" - echo "๐Ÿš€ Strategy: Images using pre-built binaries (supports both release and dev channels)" + echo "๐Ÿš€ Strategy: Images using pre-built binaries (release channel only)" echo "" case "$BUILD_TYPE" in - "development") - echo "๐Ÿ› ๏ธ Development Docker image has been built with dev-${VERSION} tags" - echo "โš ๏ธ This is a development image - not suitable for production use" - ;; "release") echo "๐Ÿš€ Release Docker image has been built with ${VERSION} tags" echo "โœ… This image is ready for production use" @@ -404,4 +378,7 @@ jobs: echo "โš ๏ธ This is a prerelease image - use with caution" echo "๐Ÿšซ Latest tag NOT created for prerelease" ;; + *) + echo "โŒ Unexpected build type: $BUILD_TYPE" + ;; esac diff --git a/Dockerfile b/Dockerfile index 0e891e6f..702482b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ FROM alpine:latest AS build ARG TARGETPLATFORM ARG BUILDPLATFORM ARG RELEASE=latest -ARG CHANNEL=release # Install dependencies for downloading and verifying binaries RUN apk add --no-cache \ @@ -27,30 +26,19 @@ RUN case "${TARGETPLATFORM}" in \ esac && \ echo "ARCH=${ARCH}" > /build/arch.env -# Download rustfs binary from dl.rustfs.com +# Download rustfs binary from dl.rustfs.com (release channel only) RUN . /build/arch.env && \ - BASE_URL="https://dl.rustfs.com/artifacts/rustfs" && \ + BASE_URL="https://dl.rustfs.com/artifacts/rustfs/release" && \ PLATFORM="linux" && \ if [ "${RELEASE}" = "latest" ]; then \ - # Download latest version from specified channel \ - if [ "${CHANNEL}" = "dev" ]; then \ - PACKAGE_NAME="rustfs-${PLATFORM}-${ARCH}-dev-latest.zip"; \ - DOWNLOAD_URL="${BASE_URL}/dev/${PACKAGE_NAME}"; \ - echo "๐Ÿ“ฅ Downloading latest dev build: ${PACKAGE_NAME}"; \ - else \ - PACKAGE_NAME="rustfs-${PLATFORM}-${ARCH}-latest.zip"; \ - DOWNLOAD_URL="${BASE_URL}/release/${PACKAGE_NAME}"; \ - echo "๐Ÿ“ฅ Downloading latest release build: ${PACKAGE_NAME}"; \ - fi; \ - elif [ "${CHANNEL}" = "dev" ]; then \ - # Download specific dev version \ - PACKAGE_NAME="rustfs-${PLATFORM}-${ARCH}-${RELEASE}.zip"; \ - DOWNLOAD_URL="${BASE_URL}/dev/${PACKAGE_NAME}"; \ - echo "๐Ÿ“ฅ Downloading specific dev version: ${PACKAGE_NAME}"; \ + # Download latest release version \ + PACKAGE_NAME="rustfs-${PLATFORM}-${ARCH}-latest.zip"; \ + DOWNLOAD_URL="${BASE_URL}/${PACKAGE_NAME}"; \ + echo "๐Ÿ“ฅ Downloading latest release build: ${PACKAGE_NAME}"; \ else \ # Download specific release version \ PACKAGE_NAME="rustfs-${PLATFORM}-${ARCH}-v${RELEASE}.zip"; \ - DOWNLOAD_URL="${BASE_URL}/release/${PACKAGE_NAME}"; \ + DOWNLOAD_URL="${BASE_URL}/${PACKAGE_NAME}"; \ echo "๐Ÿ“ฅ Downloading specific release version: ${PACKAGE_NAME}"; \ fi && \ echo "๐Ÿ”— Download URL: ${DOWNLOAD_URL}" && \ @@ -71,7 +59,6 @@ FROM alpine:latest # Set build arguments and labels ARG RELEASE=latest -ARG CHANNEL=release ARG BUILD_DATE ARG VCS_REF @@ -80,7 +67,6 @@ LABEL name="RustFS" \ maintainer="RustFS Team " \ version="${RELEASE}" \ release="${RELEASE}" \ - channel="${CHANNEL}" \ build-date="${BUILD_DATE}" \ vcs-ref="${VCS_REF}" \ summary="RustFS is a high-performance distributed object storage system written in Rust, compatible with S3 API." \