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 # 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 # Create blank project 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 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 && \ source /env-cargo && \ cargo install --path . --target "${CARGO_TARGET}" COPY tailwind.* ./ RUN ./tailwindcss -i tailwind.css -o index.css --minify # Runtime image FROM docker.io/alpine WORKDIR /homepage ARG GID=8686 ARG UID=8686 RUN addgroup -g ${GID} homepage && \ adduser -u ${UID} -D -H -G homepage homepage USER homepage:homepage EXPOSE 8080 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"]