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

Build & publish docker images #62

Closed
simonsan opened this issue Nov 16, 2024 · 5 comments · Fixed by #64
Closed

Build & publish docker images #62

simonsan opened this issue Nov 16, 2024 · 5 comments · Fixed by #64
Labels
A-ci Area: Pull requests that update CI code A-packaging Area: related to packaging C-enhancement Category: New feature or request

Comments

@simonsan
Copy link
Contributor

We can check here: https://github.com/rustic-rs/rustic/blob/main/.github/workflows/release-image.yml
and restic/rest-server#258

@simonsan simonsan added A-ci Area: Pull requests that update CI code A-packaging Area: related to packaging C-enhancement Category: New feature or request labels Nov 16, 2024
@simonsan
Copy link
Contributor Author

simonsan commented Nov 16, 2024

Because you both, @mueckinger (rustic-rs/rustic#1297) @timtorChen (rustic-rs/rustic#1351), were contributing to the Docker ecosystem in rustic, I'm tagging you here. Does someone of you want to tackle this issue and create a Dockerfile? It would be really helpful! 🫂 🚀

@timtorChen
Copy link
Contributor

timtorChen commented Nov 17, 2024

I can take this issue. Is there any preference for buid process?

  1. After Gtihub relase, copy the binary file into the Docker image. (https://github.com/rustic-rs/rustic/blob/main/Dockerfile)
  2. Build binary in the Docker build time (https://github.com/timtorChen/rustic-exporter/blob/main/Dockerfile)

If there is no preference, I will create a PR with method 1.

@simonsan
Copy link
Contributor Author

simonsan commented Nov 17, 2024

Super! 👍🏽 yeah, 1. is preferred, I would say.

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";\
    fi; \
    wget https://github.com/rustic-rs/rustic_server/releases/download/${RUSTIC_SERVER_VERSION}/${ASSET} && \
    tar -xf ${ASSET} && \
    mkdir /etc_files && \
    touch /etc_files/passwd && \
    touch /etc_files/group

FROM scratch
COPY --from=builder /rustic_server-x86_64-unknown-linux-musl /
COPY --from=builder /etc_files/ /etc/
ENTRYPOINT ["/rustic-server"]

This is 1. adopted to this repo, but we would still need to expose setting ports for example and other settings. I also pushed a /health endpoint in 32dc6e1 that returns a 200 OK http status code when running, the uptime, and a timestamp when the response was sent (for logging). it's reachable under /health/live.

@simonsan
Copy link
Contributor Author

simonsan commented Nov 17, 2024

Current help for serve options:

Start a server with the specified configuration

Usage: rustic-server.exe serve [OPTIONS]

Options:
      --listen <LISTEN>                IP address and port to bind to [env: RUSTIC_SERVER_LISTEN=]
      --path <DATA_DIR>                Path to the data directory [env: RUSTIC_SERVER_DATA_DIR=]
      --max-size <QUOTA>               Optional maximum size (quota) of a repository in bytes [env:
                                       RUSTIC_SERVER_QUOTA=]
  -v, --verbose                        Enable verbose logging [env: RUSTIC_SERVER_VERBOSE=]
  -c, --config <CONFIG>                Use the specified config file [env:
                                       RUSTIC_SERVER_CONFIG_PATH=]
      --no-auth                        Disable .htpasswd authentication [env:
                                       RUSTIC_SERVER_DISABLE_AUTH=]
      --htpasswd-file <HTPASSWD_FILE>  Optional location of .htpasswd file (default: "<data
                                       directory>/.htpasswd") [env: RUSTIC_SERVER_HTPASSWD_FILE=]
      --private-repos                  Users can only access their private repositories [env:
                                       RUSTIC_SERVER_PRIVATE_REPOS=]
      --append-only                    Enable append only mode [env: RUSTIC_SERVER_APPEND_ONLY=]
      --acl-path <ACL_PATH>            Full path including file name to read from. Governs per-repo
                                       ACLs. (default: "<data directory>/acl.toml") [env:
                                       RUSTIC_SERVER_ACL_PATH=]
      --tls                            Enable TLS support [env: RUSTIC_SERVER_DISABLE_TLS=]
      --tls-key <TLS_KEY>              Optional path to the TLS key file [env:
                                       RUSTIC_SERVER_TLS_KEY=]
      --tls-cert <TLS_CERT>            Optional path to the TLS certificate file [env:
                                       RUSTIC_SERVER_TLS_CERT=]
      --log <LOG_FILE>                 Write HTTP requests in the combined log format to the
                                       specified filename [env: RUSTIC_SERVER_LOG_FILE=]
  -h, --help                           Print help (see more with '--help')

Looking at it, the easiest would probably expose the env vars, so I added them to all the possible options now, will be in the next release.

@timtorChen
Copy link
Contributor

timtorChen commented Nov 17, 2024

Setting HEALTHCHECK would need some extra work for stratch image.
Is compiling musl curl or wget in docker image a good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ci Area: Pull requests that update CI code A-packaging Area: related to packaging C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants