diff --git a/.github/workflows/cross-ci.yml b/.github/workflows/cross-ci.yml index 4a8b3b8..53986bd 100644 --- a/.github/workflows/cross-ci.yml +++ b/.github/workflows/cross-ci.yml @@ -67,6 +67,12 @@ jobs: target: aarch64-unknown-linux-gnu architecture: arm64 use-cross: true + # Check because of Container images for rustic-rs + - os: ubuntu-latest + os-name: linux + target: aarch64-unknown-linux-musl + architecture: arm64 + use-cross: true - os: ubuntu-latest os-name: linux target: i686-unknown-linux-gnu diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 86a95ad..10d7bf6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -68,6 +68,12 @@ jobs: architecture: arm64 binary-postfix: "" use-cross: true + - os: ubuntu-latest + os-name: linux + target: aarch64-unknown-linux-musl + architecture: arm64 + binary-postfix: "" + use-cross: true - os: ubuntu-latest os-name: linux target: i686-unknown-linux-gnu diff --git a/.github/workflows/prebuilt-pr.yml b/.github/workflows/prebuilt-pr.yml index 1e2c6d3..31d48b5 100644 --- a/.github/workflows/prebuilt-pr.yml +++ b/.github/workflows/prebuilt-pr.yml @@ -62,6 +62,12 @@ jobs: architecture: arm64 binary-postfix: "" use-cross: true + - os: ubuntu-latest + os-name: linux + target: aarch64-unknown-linux-musl + architecture: arm64 + binary-postfix: "" + use-cross: true - os: ubuntu-latest os-name: linux target: i686-unknown-linux-gnu diff --git a/.github/workflows/release-cd.yml b/.github/workflows/release-cd.yml index d48bfa0..d5e4174 100644 --- a/.github/workflows/release-cd.yml +++ b/.github/workflows/release-cd.yml @@ -53,6 +53,12 @@ jobs: architecture: arm64 binary-postfix: "" use-cross: true + - os: ubuntu-latest + os-name: linux + target: aarch64-unknown-linux-musl + architecture: arm64 + binary-postfix: "" + use-cross: true - os: ubuntu-latest os-name: linux target: i686-unknown-linux-gnu diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..200302c --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,26 @@ +name: Release Docker Image + +on: [release] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3 + + - name: Login to Docker Hub + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6 + with: + context: containers + push: true + platforms: linux/amd64,linux/arm64 + tags: ghcr.io/rustic-rs/rustic_server:latest,ghcr.io/rustic-rs/rustic_server:${{ github.ref_name }} + build-args: RUSTIC_SERVER_VERSION=${{ github.ref_name }} diff --git a/.gitignore b/.gitignore index 7a445a7..b6a3c33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.venv # Generated by Cargo # will have compiled files and executables /target/ @@ -14,4 +15,5 @@ tests/fixtures/rest_server repo_remove_me* __* ci_repo -repo_not_* \ No newline at end of file +repo_not_* +containers/volumes \ No newline at end of file diff --git a/.justfile b/.justfile index 5ec5cbb..b0d56b2 100644 --- a/.justfile +++ b/.justfile @@ -94,3 +94,12 @@ hurl: dbg-test test_name $RUST_LOG="debug": cargo test --package rustic_server --lib -- {{ test_name }} --exact --nocapture --show-output + +build-docker version="0.4.0": + podman build containers --build-arg RUSTIC_SERVER_VERSION=v{{ version }} --format docker --tag rustic_server:v{{ version }} + +server-up: + uv --directory containers run podman-compose -f docker-compose.yml up --detach + +server-down: + uv --directory containers run podman-compose -f docker-compose.yml down diff --git a/build-dependencies.just b/build-dependencies.just index 3701f83..eefb954 100644 --- a/build-dependencies.just +++ b/build-dependencies.just @@ -4,3 +4,8 @@ install-default-x86_64-unknown-linux-musl: sudo apt-get update sudo apt-get install -y musl-tools + +# Install dependencies for the default feature on aarch64-unknown-linux-musl +install-default-aarch64-unknown-linux-musl: + sudo apt-get update + sudo apt-get install -y musl-tools diff --git a/containers/Dockerfile b/containers/Dockerfile new file mode 100644 index 0000000..d90331f --- /dev/null +++ b/containers/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine AS builder +ARG RUSTIC_SERVER_VERSION +ARG TARGETARCH +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + ASSET="rustic_server-x86_64-unknown-linux-musl.tar.xz";\ + elif [ "$TARGETARCH" = "arm64" ]; then \ + ASSET="rustic_server-aarch64-unknown-linux-musl.tar.xz"; \ + fi; \ + wget https://github.com/rustic-rs/rustic_server/releases/download/${RUSTIC_SERVER_VERSION}/${ASSET} && \ + tar -xf ${ASSET} --strip-components=1 && \ + mkdir /etc_files && \ + touch /etc_files/passwd && \ + touch /etc_files/group + +FROM scratch +COPY --from=builder /rustic-server /rustic-server +COPY --from=builder /etc_files/ /etc/ +EXPOSE 8000 +ENTRYPOINT ["/rustic-server", "serve"] +HEALTHCHECK --interval=90s --timeout=10s --retries=3 \ + CMD curl --fail -s http://localhost:8000/health/live || exit 1 diff --git a/containers/docker-compose.yml b/containers/docker-compose.yml new file mode 100644 index 0000000..6ac4761 --- /dev/null +++ b/containers/docker-compose.yml @@ -0,0 +1,52 @@ +services: + rustic-server: + image: rustic-server:latest + build: + context: . + dockerfile: Dockerfile + args: + RUSTIC_SERVER_VERSION: "v0.4.0" # Replace with the actual version + ports: + - "8000:8000" + volumes: + - ./volumes/config:/etc/rustic-server/config:ro + - ./volumes/certs:/etc/rustic-server/certs:ro + - ./volumes/data:/var/lib/rustic-server/data + - ./volumes/logs:/var/log/ + environment: + - RUSTIC_SERVER_LISTEN=0.0.0.0:8000 + - RUSTIC_SERVER_DATA_DIR=/var/lib/rustic-server/data + - RUSTIC_SERVER_QUOTA=0 # 0 means no quota + - RUSTIC_SERVER_VERBOSE=false + # - RUSTIC_SERVER_CONFIG_PATH=/etc/rustic-server/config/server.toml + - RUSTIC_SERVER_DISABLE_AUTH=false + - RUSTIC_SERVER_HTPASSWD_FILE=/var/lib/rustic-server/data/.htpasswd + - RUSTIC_SERVER_PRIVATE_REPOS=true + - RUSTIC_SERVER_APPEND_ONLY=false + - RUSTIC_SERVER_ACL_PATH=/etc/rustic-server/config/acl.toml + - RUSTIC_SERVER_DISABLE_TLS=false + - RUSTIC_SERVER_TLS_KEY=/etc/rustic-server/certs/server.key + - RUSTIC_SERVER_TLS_CERT=/etc/rustic-server/certs/server.crt + - RUSTIC_SERVER_LOG_FILE=/var/log/rustic-server.log + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "curl", "--fail", "-s", "http://localhost:8000/health/live"] + interval: 90s + timeout: 10s + retries: 3 + networks: + - rustic-network + deploy: + resources: + limits: + cpus: '0.50' + memory: 512M + restart: unless-stopped + +networks: + rustic-network: + driver: bridge diff --git a/dist-workspace.toml b/dist-workspace.toml index f3ea675..ef83c14 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -16,6 +16,7 @@ targets = [ # "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc", + "aarch64-unknown-linux-musl" ] # Path that installers should place binaries in install-path = "CARGO_HOME"