From cdeac582d5c8fc0ed0d9374d05390ccbeeaf9609 Mon Sep 17 00:00:00 2001 From: Timtor Chen Date: Sun, 17 Nov 2024 15:03:44 +0800 Subject: [PATCH 01/12] WIP fork - add dockerfile and release-image workflow --- .github/workflows/release-image.yml | 25 +++++++++++++++++++++++++ Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/release-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..e1e98c6 --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,25 @@ +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: + 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/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d039683 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +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 /usr/bin/wget /wget +COPY --from=builder /rustic-server / +COPY --from=builder /etc_files/ /etc/ +EXPOSE 8080 +ENTRYPOINT ["/rustic-server"] +HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ + CMD /wget -q --spider http://localhost:8080/health/live From 80657cbc52d9ebdff841e6477fd539f8640713d0 Mon Sep 17 00:00:00 2001 From: Timtor Chen Date: Sun, 17 Nov 2024 19:33:12 +0800 Subject: [PATCH 02/12] add arrch64 --- .github/workflows/cross-ci.yml | 6 ++++++ .github/workflows/nightly.yml | 6 ++++++ .github/workflows/prebuilt-pr.yml | 6 ++++++ .github/workflows/release-cd.yml | 6 ++++++ build-dependencies.just | 5 +++++ dist-workspace.toml | 1 + 6 files changed, 30 insertions(+) diff --git a/.github/workflows/cross-ci.yml b/.github/workflows/cross-ci.yml index 4a8b3b8..31780c6 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 + - 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/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/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/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" From ae539892084e6da0a381575a39794bb9fddac96c Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:58:02 +0100 Subject: [PATCH 03/12] use curl and add justfile support Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .justfile | 3 +++ Dockerfile | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.justfile b/.justfile index 5ec5cbb..4036060 100644 --- a/.justfile +++ b/.justfile @@ -94,3 +94,6 @@ 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 . --build-arg RUSTIC_SERVER_VERSION=v{{ version }} --format docker --tag rustic_server:v{{ version }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d039683..0317b85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,9 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \ touch /etc_files/group FROM scratch -COPY --from=builder /usr/bin/wget /wget COPY --from=builder /rustic-server / COPY --from=builder /etc_files/ /etc/ -EXPOSE 8080 +EXPOSE 8000 ENTRYPOINT ["/rustic-server"] -HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ - CMD /wget -q --spider http://localhost:8080/health/live +HEALTHCHECK --interval=90s --timeout=10s --retries=3 \ + CMD /curl --fail -s http://localhost:8000/health/live || exit 1 From 6252358f4dc2bc68234299e688bd3c6becb9f46b Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:22:46 +0100 Subject: [PATCH 04/12] move Dockerfile to /containers Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- Dockerfile => containers/Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dockerfile => containers/Dockerfile (100%) diff --git a/Dockerfile b/containers/Dockerfile similarity index 100% rename from Dockerfile rename to containers/Dockerfile From 01980948356f64faad34b68d93b844e0ed5da8d6 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:24:42 +0100 Subject: [PATCH 05/12] adapt justfile Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.justfile b/.justfile index 4036060..c0b2775 100644 --- a/.justfile +++ b/.justfile @@ -96,4 +96,4 @@ 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 . --build-arg RUSTIC_SERVER_VERSION=v{{ version }} --format docker --tag rustic_server:v{{ version }} \ No newline at end of file + podman build containers --build-arg RUSTIC_SERVER_VERSION=v{{ version }} --format docker --tag rustic_server:v{{ version }} \ No newline at end of file From 94a900a9a0ffa5c5ee3df4c392763705ee1308a7 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:59:43 +0100 Subject: [PATCH 06/12] change context to account for subdirectory Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .github/workflows/release-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml index e1e98c6..200302c 100644 --- a/.github/workflows/release-image.yml +++ b/.github/workflows/release-image.yml @@ -19,6 +19,7 @@ jobs: - 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 }} From 37ee1030993b8758f4c3c0efc1216a0b892ddf0d Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:25:07 +0100 Subject: [PATCH 07/12] add initial docker-compose (to be tested still) Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- containers/docker-compose.yml | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 containers/docker-compose.yml diff --git a/containers/docker-compose.yml b/containers/docker-compose.yml new file mode 100644 index 0000000..d3a82bf --- /dev/null +++ b/containers/docker-compose.yml @@ -0,0 +1,53 @@ +version: '3.9' + +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: + - ./config:/etc/rustic-server/config:ro + - ./certs:/etc/rustic-server/certs:ro + - ./data:/var/lib/rustic-server/data + - ./logs:/var/log/ + environment: + - RUSTIC_SERVER_LISTEN=127.0.0.1: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 + +networks: + rustic-network: + driver: bridge \ No newline at end of file From 5b49fa7d5d84a6fc358fad1c2dc264cd569b02ff Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:38:28 +0100 Subject: [PATCH 08/12] fix volumes and curl Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- containers/Dockerfile | 2 +- containers/docker-compose.yml | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/containers/Dockerfile b/containers/Dockerfile index 0317b85..dfe1e31 100644 --- a/containers/Dockerfile +++ b/containers/Dockerfile @@ -18,4 +18,4 @@ COPY --from=builder /etc_files/ /etc/ EXPOSE 8000 ENTRYPOINT ["/rustic-server"] HEALTHCHECK --interval=90s --timeout=10s --retries=3 \ - CMD /curl --fail -s http://localhost:8000/health/live || exit 1 + CMD curl --fail -s http://localhost:8000/health/live || exit 1 diff --git a/containers/docker-compose.yml b/containers/docker-compose.yml index d3a82bf..50fba11 100644 --- a/containers/docker-compose.yml +++ b/containers/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.9' - services: rustic-server: image: rustic-server:latest @@ -11,10 +9,10 @@ services: ports: - "8000:8000" volumes: - - ./config:/etc/rustic-server/config:ro - - ./certs:/etc/rustic-server/certs:ro - - ./data:/var/lib/rustic-server/data - - ./logs:/var/log/ + - ./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=127.0.0.1:8000 - RUSTIC_SERVER_DATA_DIR=/var/lib/rustic-server/data @@ -36,7 +34,7 @@ services: max-size: "10m" max-file: "3" healthcheck: - test: ["CMD", "/curl", "--fail", "-s", "http://localhost:8000/health/live"] + test: ["CMD", "curl", "--fail", "-s", "http://localhost:8000/health/live"] interval: 90s timeout: 10s retries: 3 From b6f142d4ff7ff1a174302c0127118d2f9e8cb5a2 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:49:43 +0100 Subject: [PATCH 09/12] use serve as entrypoint Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- containers/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/containers/Dockerfile b/containers/Dockerfile index dfe1e31..d90331f 100644 --- a/containers/Dockerfile +++ b/containers/Dockerfile @@ -13,9 +13,9 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \ touch /etc_files/group FROM scratch -COPY --from=builder /rustic-server / +COPY --from=builder /rustic-server /rustic-server COPY --from=builder /etc_files/ /etc/ EXPOSE 8000 -ENTRYPOINT ["/rustic-server"] +ENTRYPOINT ["/rustic-server", "serve"] HEALTHCHECK --interval=90s --timeout=10s --retries=3 \ CMD curl --fail -s http://localhost:8000/health/live || exit 1 From 0db5f14fd166dad2712f0190d2b32cb7201f702d Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 02:24:17 +0100 Subject: [PATCH 10/12] correct configuration Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .gitignore | 4 +++- containers/docker-compose.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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/containers/docker-compose.yml b/containers/docker-compose.yml index 50fba11..e5ce433 100644 --- a/containers/docker-compose.yml +++ b/containers/docker-compose.yml @@ -14,11 +14,11 @@ services: - ./volumes/data:/var/lib/rustic-server/data - ./volumes/logs:/var/log/ environment: - - RUSTIC_SERVER_LISTEN=127.0.0.1:8000 + - 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_CONFIG_PATH= - RUSTIC_SERVER_DISABLE_AUTH=false - RUSTIC_SERVER_HTPASSWD_FILE=/var/lib/rustic-server/data/.htpasswd - RUSTIC_SERVER_PRIVATE_REPOS=true From 592957a73356d8bfb1f5495e55844d3447d17ef5 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 02:59:21 +0100 Subject: [PATCH 11/12] fix config not found due to empty, but set env var Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .justfile | 8 +++++++- containers/docker-compose.yml | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.justfile b/.justfile index c0b2775..b0d56b2 100644 --- a/.justfile +++ b/.justfile @@ -96,4 +96,10 @@ 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 }} \ No newline at end of file + 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/containers/docker-compose.yml b/containers/docker-compose.yml index e5ce433..6ac4761 100644 --- a/containers/docker-compose.yml +++ b/containers/docker-compose.yml @@ -18,7 +18,7 @@ services: - 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= + # - 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 @@ -45,7 +45,8 @@ services: limits: cpus: '0.50' memory: 512M + restart: unless-stopped networks: rustic-network: - driver: bridge \ No newline at end of file + driver: bridge From f6e4450021f027166d699ca836267699fb087476 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Nov 2024 03:21:34 +0100 Subject: [PATCH 12/12] ci: add comment and remove unneded attrib from matrix --- .github/workflows/cross-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cross-ci.yml b/.github/workflows/cross-ci.yml index 31780c6..53986bd 100644 --- a/.github/workflows/cross-ci.yml +++ b/.github/workflows/cross-ci.yml @@ -67,11 +67,11 @@ 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 - binary-postfix: "" use-cross: true - os: ubuntu-latest os-name: linux