-
Notifications
You must be signed in to change notification settings - Fork 4
Allow switching category automatically to make torrents linked #14
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
base: dioxus-switch
Are you sure you want to change the base?
Changes from all commits
83555dd
2a7927e
f148463
f29407c
24b3259
d00500c
e170b52
616c707
271f841
6096f2a
f4688e3
888baa3
6c6fd36
ff9e171
bae6ba5
ba6a041
2856baa
c0a1c78
a1137f4
e9ac197
e11c2fa
615e4ae
9b626d9
7ba8973
c39b275
63c672c
f17b136
2410e56
0516b3e
ac47ab4
f80d633
83bee33
cec9691
a942b54
f744c10
659ef4c
8342df8
06a0e33
3dba21b
c479504
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| .git | ||
| .github | ||
| .agents | ||
|
|
||
| target | ||
| node_modules | ||
| test-results | ||
|
|
||
| data.db | ||
| *.db | ||
| *.bak | ||
| *.backup | ||
| *.db.bak.* | ||
| *.sqlite | ||
| *.sqlite3 | ||
|
|
||
| .DS_Store | ||
|
|
||
| config.toml | ||
| finn.json | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,98 @@ | ||
| # syntax=docker/dockerfile:1.3-labs | ||
| # syntax=docker/dockerfile:1.7-labs | ||
|
|
||
| # The above line is so we can use can use heredocs in Dockerfiles. No more && and \! | ||
| # https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ | ||
|
|
||
| FROM rust:1.91 AS build | ||
|
|
||
| RUN <<EOF | ||
| set -e | ||
| cargo new --lib app/mlm_db | ||
| cargo new --lib app/mlm_mam | ||
| cargo new --lib app/mlm_parse | ||
| cargo new --lib app/mlm_meta | ||
| cargo new --lib app/mlm_core | ||
| cargo new --lib app/mlm_web_askama | ||
| cargo new --bin app/mlm_web_dioxus | ||
| cargo new --bin app/server | ||
| touch /app/mlm_web_dioxus/src/lib.rs | ||
| EOF | ||
|
|
||
| # Capture dependencies | ||
| COPY Cargo.toml Cargo.lock /app/ | ||
| COPY mlm_db/Cargo.toml /app/mlm_db/ | ||
| COPY mlm_mam/Cargo.toml /app/mlm_mam/ | ||
| COPY mlm_parse/Cargo.toml /app/mlm_parse/ | ||
| COPY mlm_meta/Cargo.toml /app/mlm_meta/ | ||
| COPY mlm_core/Cargo.toml /app/mlm_core/ | ||
| COPY mlm_web_askama/Cargo.toml /app/mlm_web_askama/ | ||
| COPY mlm_web_dioxus/Cargo.toml /app/mlm_web_dioxus/ | ||
| COPY server/Cargo.toml /app/server/ | ||
|
|
||
| # This step compiles only our dependencies and saves them in a layer. This is the most impactful time savings | ||
| # Note the use of --mount=type=cache. On subsequent runs, we'll have the crates already downloaded | ||
| FROM rust:1.91 AS chef | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends clang mold pkg-config \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| RUN --mount=type=cache,id=mlm-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ | ||
| --mount=type=cache,id=mlm-cargo-git,target=/usr/local/cargo/git,sharing=locked \ | ||
| cargo install cargo-chef --locked \ | ||
| && cargo install dioxus-cli --version 0.7.3 --locked | ||
| WORKDIR /app | ||
| RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release | ||
|
|
||
| # Copy our sources | ||
| COPY ./mlm_db /app/mlm_db | ||
| COPY ./mlm_mam /app/mlm_mam | ||
| COPY ./mlm_parse /app/mlm_parse | ||
| COPY ./mlm_meta /app/mlm_meta | ||
| COPY ./mlm_core /app/mlm_core | ||
| COPY ./mlm_web_askama /app/mlm_web_askama | ||
| COPY ./mlm_web_dioxus /app/mlm_web_dioxus | ||
| COPY ./server /app/server | ||
| FROM chef AS planner | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY server/Cargo.toml server/Cargo.toml | ||
| COPY server/build.rs server/build.rs | ||
| COPY mlm_web_api/Cargo.toml mlm_web_api/Cargo.toml | ||
| COPY mlm_db/Cargo.toml mlm_db/Cargo.toml | ||
| COPY mlm_parse/Cargo.toml mlm_parse/Cargo.toml | ||
| COPY mlm_mam/Cargo.toml mlm_mam/Cargo.toml | ||
| COPY mlm_meta/Cargo.toml mlm_meta/Cargo.toml | ||
| COPY mlm_core/Cargo.toml mlm_core/Cargo.toml | ||
| COPY mlm_web_askama/Cargo.toml mlm_web_askama/Cargo.toml | ||
| COPY mlm_web_dioxus/Cargo.toml mlm_web_dioxus/Cargo.toml | ||
| RUN mkdir -p \ | ||
| server/src/bin \ | ||
| mlm_web_api/src \ | ||
| mlm_db/src \ | ||
| mlm_parse/src \ | ||
| mlm_mam/src \ | ||
| mlm_meta/src \ | ||
| mlm_core/src \ | ||
| mlm_web_askama/src \ | ||
| mlm_web_dioxus/src \ | ||
| && touch \ | ||
| server/src/lib.rs \ | ||
| server/src/main.rs \ | ||
| server/src/bin/create_test_db.rs \ | ||
| server/src/bin/libation_unmapped_categories.rs \ | ||
| server/src/bin/mock_server.rs \ | ||
| mlm_web_api/src/lib.rs \ | ||
| mlm_db/src/lib.rs \ | ||
| mlm_parse/src/lib.rs \ | ||
| mlm_mam/src/lib.rs \ | ||
| mlm_meta/src/lib.rs \ | ||
| mlm_core/src/lib.rs \ | ||
| mlm_web_askama/src/lib.rs \ | ||
| mlm_web_dioxus/src/lib.rs \ | ||
| mlm_web_dioxus/src/main.rs \ | ||
| && cargo chef prepare --recipe-path recipe.json | ||
|
|
||
| # A bit of magic here! | ||
| # * We're mounting that cache again to use during the build, otherwise it's not present and we'll have to download those again - bad! | ||
| # * EOF syntax is neat but not without its drawbacks. We need to `set -e`, otherwise a failing command is going to continue on | ||
| # * Rust here is a bit fiddly, so we'll touch the files (even though we copied over them) to force a new build | ||
| RUN --mount=type=cache,target=/usr/local/cargo/registry <<EOF | ||
| set -e | ||
| # update timestamps to force a new build | ||
| touch /app/mlm_db/src/lib.rs | ||
| touch /app/mlm_mam/src/lib.rs | ||
| touch /app/mlm_parse/src/lib.rs | ||
| touch /app/mlm_meta/src/lib.rs | ||
| touch /app/mlm_core/src/lib.rs | ||
| touch /app/mlm_web_askama/src/lib.rs | ||
| touch /app/mlm_web_dioxus/src/lib.rs | ||
| touch /app/mlm_web_dioxus/src/main.rs | ||
| touch /app/server/src/main.rs | ||
| cargo build --release | ||
| EOF | ||
| FROM chef AS builder | ||
| COPY --from=planner /app/recipe.json recipe.json | ||
| RUN --mount=type=cache,id=mlm-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ | ||
| --mount=type=cache,id=mlm-cargo-git,target=/usr/local/cargo/git,sharing=locked \ | ||
| --mount=type=cache,id=mlm-target,target=/app/target,sharing=locked \ | ||
| cargo chef cook --release --recipe-path recipe.json | ||
|
|
||
| CMD ["/app/target/release/mlm"] | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY server server | ||
| COPY mlm_web_api mlm_web_api | ||
| COPY mlm_db mlm_db | ||
| COPY mlm_parse mlm_parse | ||
| COPY mlm_mam mlm_mam | ||
| COPY mlm_meta mlm_meta | ||
| COPY mlm_core mlm_core | ||
| COPY mlm_web_askama mlm_web_askama | ||
| COPY mlm_web_dioxus mlm_web_dioxus | ||
| RUN --mount=type=cache,id=mlm-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ | ||
| --mount=type=cache,id=mlm-cargo-git,target=/usr/local/cargo/git,sharing=locked \ | ||
| --mount=type=cache,id=mlm-target,target=/app/target,sharing=locked \ | ||
| cargo build --release --bin mlm && \ | ||
| cp /app/target/release/mlm /app/mlm | ||
| RUN --mount=type=cache,id=mlm-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \ | ||
| --mount=type=cache,id=mlm-cargo-git,target=/usr/local/cargo/git,sharing=locked \ | ||
| --mount=type=cache,id=mlm-target,target=/app/target,sharing=locked \ | ||
| cd /app/mlm_web_dioxus && /usr/local/cargo/bin/dx build --release --fullstack --skip-assets && \ | ||
| mkdir -p /app/dx_output && cp -r /app/target/dx/mlm_web_dioxus /app/dx_output/ | ||
|
|
||
| # Again, our final image is the same - a slim base and just our app | ||
| FROM debian:trixie-slim AS app | ||
| RUN apt update && apt install -y ca-certificates && apt clean | ||
| COPY ./server/assets /server/assets | ||
| COPY --from=build /app/target/release/mlm /mlm | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends ca-certificates \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && groupadd --gid 1000 mlm \ | ||
| && useradd --uid 1000 --gid 1000 --shell /usr/sbin/nologin mlm \ | ||
| && mkdir -p /data /config /dioxus-public \ | ||
| && chown -R mlm:mlm /data /config /dioxus-public | ||
| COPY --chown=mlm:mlm server/assets /server/assets | ||
| COPY --chown=mlm:mlm entrypoint.sh /entrypoint.sh | ||
| COPY --from=builder /app/mlm /mlm | ||
| COPY --from=builder /app/dx_output/mlm_web_dioxus/release/web/public /dioxus-public | ||
| ENV MLM_LOG_DIR="" | ||
| ENV MLM_CONFIG_FILE="/config/config.toml" | ||
| ENV MLM_DB_FILE="/data/data.db" | ||
| ENV DIOXUS_PUBLIC_PATH="/dioxus-public" | ||
| USER mlm | ||
| ENTRYPOINT ["/entrypoint.sh"] | ||
| CMD ["/mlm"] | ||
|
Comment on lines
80
to
98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run the runtime image as a non-root user. The final stage never switches away from root, so any compromise in 🧰 Tools🪛 Checkov (3.2.508)[low] 1-41: Ensure that HEALTHCHECK instructions have been added to container images (CKV_DOCKER_2) [low] 1-41: Ensure that a user for the container has been created (CKV_DOCKER_3) 🪛 Hadolint (2.14.0)[info] 33-33: Delete the apt lists (/var/lib/apt/lists) after installing something (DL3009) [warning] 33-33: Do not use apt as it is meant to be an end-user tool, use apt-get or apt-cache instead (DL3027) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Fix ownership of database file if it exists and is root-owned | ||
| DB_FILE="/data/data.db" | ||
| if [ -f "$DB_FILE" ] && [ "$(stat -c '%U' "$DB_FILE" 2>/dev/null)" = "root" ]; then | ||
| echo "Fixing ownership of $DB_FILE" | ||
| chown mlm:mlm "$DB_FILE" | ||
| fi | ||
|
|
||
| # Execute the main process | ||
| exec /mlm "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider adding
.envfiles to the exclusions.The current exclusions look comprehensive. If the project uses
.envfiles for secrets or local configuration, consider adding them to prevent accidental inclusion in the Docker build context:📝 Committable suggestion
🤖 Prompt for AI Agents