From ac9946e1a4ceabb3bb36ed39b89cd2391b427c5f Mon Sep 17 00:00:00 2001 From: xiaomage Date: Wed, 21 Jan 2026 16:49:27 +0800 Subject: [PATCH] add dockerfile and docker build workflow support --- .github/workflows/docker.yml | 38 ++++++++++++++++++++++++++++++++++++ Dockerfile | 16 +++++++++++++++ docker/docker-compose.yml | 25 ++++++++++++------------ 3 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..da6d7f7 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,38 @@ +name: Build and push docker image + +on: + workflow_run: + workflows: [ "Build and Release" ] + types: [ completed ] + +permissions: + contents: read + +env: + image_tag: ${{ github.event.workflow_run.head_branch }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + rustfs/rc:${{ env.image_tag }} + rustfs/rc:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fbb8297 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM rust:1.92.0-alpine3.23 AS builder + +LABEL maintainer="hello@rustfs.com" + +WORKDIR /app + +COPY . . + +RUN cargo build --release + +FROM alpine:3.23 + +COPY --from=builder /app/target/release/rc /usr/bin/rc +COPY --from=builder /app/LICENSE-* /licenses/ + +ENTRYPOINT ["rc"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b5d1ad2..722318c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,14 +7,14 @@ services: # RustFS - S3-compatible object storage (Tier 1) rustfs: - image: rustfs/rustfs:latest - container_name: rc-test-rustfs + image: rustfs/rustfs:1.0.0-alpha.80 + container_name: rustfs ports: - "9000:9000" # S3 API - "9001:9001" # Console environment: - RUSTFS_ROOT_USER: accesskey - RUSTFS_ROOT_PASSWORD: secretkey + RUSTFS_ROOT_USER: rustfsadmin + RUSTFS_ROOT_PASSWORD: rustfsadmin RUSTFS_VOLUMES: /data RUSTFS_ADDRESS: ":9000" RUSTFS_CONSOLE_ENABLE: "true" @@ -22,7 +22,7 @@ services: volumes: - rustfs-data:/data healthcheck: - test: ["CMD", "curl", "-sf", "http://localhost:9000/minio/health/live"] + test: ["CMD", "curl", "-sf", "http://127.0.0.1:9000/health"] interval: 10s timeout: 5s retries: 5 @@ -32,18 +32,17 @@ services: # Initialize RustFS - create test buckets using mc client rustfs-init: - image: quay.io/minio/mc:latest - container_name: rc-test-rustfs-init + image: rustfs/rc:latest + container_name: rc-init depends_on: - rustfs: - condition: service_healthy + - rustfs entrypoint: > /bin/sh -c " - mc alias set local http://rustfs:9000 accesskey secretkey; - mc mb local/test-bucket --ignore-existing; - mc mb local/another-bucket --ignore-existing; + until (/usr/bin/rc alias set rustfs http://rustfs:9000 rustfsadmin rustfsadmin) do echo '...waiting...' && sleep 1; done; + /usr/bin/rc mb rustfs/test-bucket; + /usr/bin/rc mb rustfs/another-bucket; echo 'RustFS initialization complete'; - exit 0; + tail -f /dev/null " networks: - rc-test-network