Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add containerization #64

Merged
merged 12 commits into from
Nov 18, 2024
6 changes: 6 additions & 0 deletions .github/workflows/cross-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/prebuilt-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.venv
# Generated by Cargo
# will have compiled files and executables
/target/
Expand All @@ -14,4 +15,5 @@ tests/fixtures/rest_server
repo_remove_me*
__*
ci_repo
repo_not_*
repo_not_*
containers/volumes
9 changes: 9 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions build-dependencies.just
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions containers/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions dist-workspace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down