-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,315 additions
and
618 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
.git | ||
.git-blame-ignore | ||
.github | ||
.gitignore | ||
.vscode | ||
bin/ | ||
config.toml | ||
config.toml.local | ||
cSpell.json | ||
data.db | ||
docker/ | ||
NOTICE | ||
README.md | ||
rustfmt.toml | ||
storage/ | ||
target/ | ||
/.git | ||
/.git-blame-ignore | ||
/.github | ||
/.gitignore | ||
/.vscode | ||
/bin/ | ||
/tracker.* | ||
/cSpell.json | ||
/data.db | ||
/docker/bin/ | ||
/NOTICE | ||
/README.md | ||
/rustfmt.toml | ||
/storage/ | ||
/target/ | ||
/etc/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Container (Docker) | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- id: checkout | ||
name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- id: setup | ||
name: Setup Toolchain | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- id: build | ||
name: Build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Containerfile | ||
push: false | ||
load: true | ||
tags: torrust-tracker:local | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- id: inspect | ||
name: Inspect | ||
run: docker image inspect torrust-tracker:local | ||
|
||
- id: compose | ||
name: Compose | ||
run: docker compose build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# syntax=docker/dockerfile:latest | ||
|
||
# Torrust Tracker | ||
|
||
## Builder Image | ||
FROM rust:latest as chef | ||
WORKDIR /tmp | ||
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | ||
RUN cargo binstall --no-confirm cargo-chef cargo-nextest | ||
|
||
## Tester Image | ||
FROM rust:slim as tester | ||
WORKDIR /tmp | ||
|
||
RUN apt-get update; apt-get install -y curl sqlite3; apt-get autoclean | ||
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | ||
RUN cargo binstall --no-confirm cargo-nextest | ||
|
||
COPY ./share/ /app/share/torrust | ||
RUN mkdir -p /app/share/torrust/default/database/; \ | ||
sqlite3 /app/share/torrust/default/database/tracker.sqlite3.db "VACUUM;" | ||
|
||
COPY ./contrib/dev-tools/su-exec/ /tmp/su-exec/ | ||
RUN cc -Wall -Werror -g /tmp/su-exec/su-exec.c -o /tmp/su-exec/su-exec | ||
|
||
|
||
## Chef Prepare (look at project and see wat we need) | ||
FROM chef AS recipe | ||
WORKDIR /build/src | ||
COPY . /build/src | ||
RUN cargo chef prepare --recipe-path /build/recipe.json | ||
|
||
|
||
## Cook (debug) | ||
FROM chef AS dependencies_debug | ||
WORKDIR /build/src | ||
COPY --from=recipe /build/recipe.json /build/recipe.json | ||
RUN cargo chef cook --tests --benches --examples --workspace --all-targets --all-features --recipe-path /build/recipe.json | ||
RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/temp.tar.zst ; rm -f /build/temp.tar.zst | ||
|
||
## Cook (release) | ||
FROM chef AS dependencies | ||
WORKDIR /build/src | ||
COPY --from=recipe /build/recipe.json /build/recipe.json | ||
RUN cargo chef cook --tests --benches --examples --workspace --all-targets --all-features --recipe-path /build/recipe.json --release | ||
RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/temp.tar.zst --release ; rm -f /build/temp.tar.zst | ||
|
||
|
||
## Build Archive (debug) | ||
FROM dependencies_debug AS build_debug | ||
WORKDIR /build/src | ||
COPY . /build/src | ||
RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/torrust-tracker-debug.tar.zst | ||
|
||
## Build Archive (release) | ||
FROM dependencies AS build | ||
WORKDIR /build/src | ||
COPY . /build/src | ||
RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/torrust-tracker.tar.zst --release | ||
|
||
|
||
# Extract and Test (debug) | ||
FROM tester as test_debug | ||
WORKDIR /test | ||
COPY . /test/src/ | ||
COPY --from=build_debug \ | ||
/build/torrust-tracker-debug.tar.zst \ | ||
/test/torrust-tracker-debug.tar.zst | ||
RUN cargo nextest run --workspace-remap /test/src/ --extract-to /test/src/ --no-run --archive-file /test/torrust-tracker-debug.tar.zst | ||
RUN cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/target/ --cargo-metadata /test/src/target/nextest/cargo-metadata.json --binaries-metadata /test/src/target/nextest/binaries-metadata.json | ||
|
||
RUN mkdir -p /app/bin/; cp -l /test/src/target/debug/torrust-tracker /app/bin/torrust-tracker | ||
RUN mkdir /app/lib/; cp -l $(realpath $(ldd /app/bin/torrust-tracker | grep "libz\.so\.1" | awk '{print $3}')) /app/lib/libz.so.1 | ||
RUN chown -R root:root /app; chmod -R u=rw,go=r,a+X /app; chmod -R a+x /app/bin | ||
|
||
# Extract and Test (release) | ||
FROM tester as test | ||
WORKDIR /test | ||
COPY . /test/src | ||
COPY --from=build \ | ||
/build/torrust-tracker.tar.zst \ | ||
/test/torrust-tracker.tar.zst | ||
RUN cargo nextest run --workspace-remap /test/src/ --extract-to /test/src/ --no-run --archive-file /test/torrust-tracker.tar.zst | ||
RUN cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/target/ --cargo-metadata /test/src/target/nextest/cargo-metadata.json --binaries-metadata /test/src/target/nextest/binaries-metadata.json | ||
|
||
RUN mkdir -p /app/bin/; cp -l /test/src/target/release/torrust-tracker /app/bin/torrust-tracker | ||
RUN mkdir -p /app/lib/; cp -l $(realpath $(ldd /app/bin/torrust-tracker | grep "libz\.so\.1" | awk '{print $3}')) /app/lib/libz.so.1 | ||
RUN chown -R root:root /app; chmod -R u=rw,go=r,a+X /app; chmod -R a+x /app/bin | ||
|
||
|
||
## Runtime | ||
FROM gcr.io/distroless/cc:debug as runtime | ||
RUN ["/busybox/cp", "-sp", "/busybox/sh","/busybox/cat","/busybox/ls","/busybox/env", "/bin/"] | ||
COPY --from=tester --chmod=0555 /tmp/su-exec/su-exec /bin/su-exec | ||
|
||
ARG TORRUST_TRACKER_PATH_CONFIG="/etc/torrust/tracker/config.toml" | ||
ARG TORRUST_TRACKER_DATABASE="sqlite3" | ||
ARG USER_ID=1000 | ||
ARG UDP_PORT=6969 | ||
ARG HTTP_PORT=7070 | ||
ARG API_PORT=1212 | ||
|
||
ENV TORRUST_TRACKER_PATH_CONFIG=${TORRUST_TRACKER_PATH_CONFIG} | ||
ENV TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE} | ||
ENV USER_ID=${USER_ID} | ||
ENV UDP_PORT=${UDP_PORT} | ||
ENV HTTP_PORT=${HTTP_PORT} | ||
ENV API_PORT=${API_PORT} | ||
ENV TZ=Etc/UTC | ||
|
||
EXPOSE ${UDP_PORT}/udp | ||
EXPOSE ${HTTP_PORT}/tcp | ||
EXPOSE ${API_PORT}/tcp | ||
|
||
RUN mkdir -p /var/lib/torrust/tracker /var/log/torrust/tracker /etc/torrust/tracker | ||
|
||
ENV ENV=/etc/profile | ||
COPY --chmod=0555 ./share/container/entry_script_sh /usr/local/bin/entry.sh | ||
|
||
VOLUME ["/var/lib/torrust/tracker","/var/log/torrust/tracker","/etc/torrust/tracker"] | ||
|
||
ENV RUNTIME="runtime" | ||
ENTRYPOINT ["/usr/local/bin/entry.sh"] | ||
|
||
|
||
## Torrust-Tracker (debug) | ||
FROM runtime as debug | ||
ENV RUNTIME="debug" | ||
COPY --from=test_debug /app/ /usr/ | ||
RUN env | ||
CMD ["sh"] | ||
|
||
## Torrust-Tracker (release) (default) | ||
FROM runtime as release | ||
ENV RUNTIME="release" | ||
COPY --from=test /app/ /usr/ | ||
# HEALTHCHECK CMD ["/usr/bin/wget", "--no-verbose", "--tries=1", "--spider", "localhost:${API_PORT}/version"] | ||
CMD ["/usr/bin/torrust-tracker"] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.