From 962df335035becb9a2cea648239040f168498f88 Mon Sep 17 00:00:00 2001 From: Viyurz Date: Sun, 25 Feb 2024 19:05:26 +0100 Subject: [PATCH] Update Dockerfile for multiarch image. --- .gitignore | 3 +- Dockerfile | 39 +++++++++++++++++++----- services.toml | 71 +++++++++++++++++++++++++++++++++++++++++++ services.toml.example | 7 ----- 4 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 services.toml delete mode 100644 services.toml.example diff --git a/.gitignore b/.gitignore index 5bd05d6..337aa98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target -.idea \ No newline at end of file +.idea +assets/index.css \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d779ebd..ad24e23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ -# Build image -FROM docker.io/rust:alpine AS build +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:x86_64-musl-stable as build_amd64 +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:aarch64-musl-stable as build_arm64 -RUN apk add --no-cache musl-dev +# Build image +FROM --platform=$BUILDPLATFORM build_${TARGETARCH} as build + +COPY --from=xx / / +ARG TARGETARCH +ARG TARGETVARIANT +ARG TARGETPLATFORM + +RUN echo "export CARGO_TARGET=${RUST_MUSL_CROSS_TARGET}" > /env-cargo WORKDIR /usr/src @@ -10,18 +18,30 @@ RUN cargo new homepage WORKDIR /usr/src/homepage +RUN source /env-cargo && \ + rustup target add "${CARGO_TARGET}" + COPY Cargo.* ./ - + # Dummy build to cache dependencies -RUN cargo build --release +RUN source /env-cargo && \ + cargo build --release --target "${CARGO_TARGET}" +RUN curl -Lo tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 && \ + chmod +x tailwindcss + COPY src ./src COPY templates ./templates # Build the actual app RUN touch src/main.rs && \ - cargo build --release + source /env-cargo && \ + cargo install --path . --target "${CARGO_TARGET}" + +COPY tailwind.* ./ + +RUN ./tailwindcss -i tailwind.css -o index.css --minify @@ -40,8 +60,13 @@ USER homepage:homepage EXPOSE 8080 -COPY --from=build /usr/src/homepage/target/release/homepage /usr/local/bin/homepage +COPY --from=build /root/.cargo/bin/homepage /usr/local/bin/homepage COPY assets ./assets +# Copy CSS generated by Tailwind +COPY --from=build /usr/src/homepage/index.css assets/ + +COPY services.toml . + ENTRYPOINT ["homepage"] diff --git a/services.toml b/services.toml new file mode 100644 index 0000000..a4fec96 --- /dev/null +++ b/services.toml @@ -0,0 +1,71 @@ +[[services]] +name = "Element" +description = "Web client of Element, an instant messaging client implementing the Matrix protocol." +domain = "element.viyurz.fr" +image = "/assets/element.png" +language = "TypeScript" +repository_url = "https://github.com/element-hq/element-web" + +[[services]] +name = "EteBase" +description = "Server for EteSync, an end-to-end encrypted contacts, calendars, tasks and notes provider." +domain = "etebase.viyurz.fr" +image = "/assets/etesync.png" +language = "Python" +repository_url = "https://github.com/etesync/server" + +[[services]] +name = "EteSync (Soon™)" +description = "Web client of EteSync, an end-to-end encrypted contacts, calendars, tasks and notes provider." +domain = "etesync.viyurz.fr" +image = "/assets/etesync.png" +language = "TypeScript" +repository_url = "https://github.com/etesync/etesync-web" + +[[services]] +name = "HedgeDoc" +description = "A real-time collaborative markdown editor." +domain = "hedgedoc.viyurz.fr" +image = "/assets/hedgedoc.png" +language = "TypeScript" +repository_url = "https://github.com/hedgedoc/hedgedoc" + +[[services]] +name = "Matrix" +description = "Synapse homeserver implemeting the Matrix protocol, an open standard for real-time communication supporting encryption and VoIP." +domain = "matrix.viyurz.fr" +image = "/assets/matrix.png" +language = "Python" +repository_url = "https://github.com/element-hq/synapse" + +[[services]] +name = "SearXNG" +description = "A privacy-respecting, hackable metasearch engine." +domain = "searx.viyurz.fr" +image = "/assets/searxng.png" +language = "Python" +repository_url = "https://github.com/searxng/searxng" + +[[services]] +name = "Stalwart Mail Server (Soon™)" +description = "Secure & Modern All-in-One Mail Server (IMAP, JMAP, SMTP)." +domain = "smtp.viyurz.fr" +image = "/assets/mail-server.png" +language = "Rust" +repository_url = "https://github.com/stalwartlabs/mail-server" + +[[services]] +name = "Stump (Soon™)" +description = "A comics, manga and digital book server with OPDS support (WIP)." +domain = "stump.viyurz.fr" +image = "/assets/stump.png" +language = "Rust / TypeScript" +repository_url = "https://github.com/stumpapp/stump" + +[[services]] +name = "Vaultwarden" +description = "Rust rewrite of the Bitwarden server, a password management service." +domain = "vw.viyurz.fr" +image = "/assets/vaultwarden.png" +language = "Rust" +repository_url = "https://github.com/dani-garcia/vaultwarden" \ No newline at end of file diff --git a/services.toml.example b/services.toml.example deleted file mode 100644 index 989b92e..0000000 --- a/services.toml.example +++ /dev/null @@ -1,7 +0,0 @@ -[[services]] -name = "My service" -description = "My service description." -domain = "myservice.viyurz.fr" -image = "/assets/myservice.png" -language = "MyLanguage" -repository_url = "https://github.com/myservicerepository"