2024-02-25 19:05:26 +01:00
|
|
|
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
|
|
|
|
|
2024-02-25 13:20:06 +01:00
|
|
|
# Build image
|
2024-02-25 19:05:26 +01:00
|
|
|
FROM --platform=$BUILDPLATFORM build_${TARGETARCH} as build
|
|
|
|
|
|
|
|
ARG TARGETARCH
|
|
|
|
ARG TARGETVARIANT
|
|
|
|
ARG TARGETPLATFORM
|
2024-02-25 13:20:06 +01:00
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
RUN echo "export CARGO_TARGET=${RUST_MUSL_CROSS_TARGET}" > /env-cargo
|
2024-02-25 13:20:06 +01:00
|
|
|
|
|
|
|
WORKDIR /usr/src
|
|
|
|
|
|
|
|
# Create blank project
|
|
|
|
RUN cargo new homepage
|
|
|
|
|
|
|
|
WORKDIR /usr/src/homepage
|
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
RUN source /env-cargo && \
|
|
|
|
rustup target add "${CARGO_TARGET}"
|
2024-02-25 13:20:06 +01:00
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
COPY Cargo.* ./
|
|
|
|
|
2024-02-25 13:20:06 +01:00
|
|
|
# Dummy build to cache dependencies
|
2024-02-25 19:05:26 +01:00
|
|
|
RUN source /env-cargo && \
|
|
|
|
cargo build --release --target "${CARGO_TARGET}"
|
2024-02-25 13:20:06 +01:00
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
RUN curl -Lo tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 && \
|
|
|
|
chmod +x tailwindcss
|
|
|
|
|
2024-02-25 13:20:06 +01:00
|
|
|
COPY src ./src
|
|
|
|
|
|
|
|
COPY templates ./templates
|
|
|
|
|
|
|
|
# Build the actual app
|
|
|
|
RUN touch src/main.rs && \
|
2024-02-25 19:05:26 +01:00
|
|
|
source /env-cargo && \
|
|
|
|
cargo install --path . --target "${CARGO_TARGET}"
|
|
|
|
|
|
|
|
COPY tailwind.* ./
|
|
|
|
|
|
|
|
RUN ./tailwindcss -i tailwind.css -o index.css --minify
|
2024-02-25 13:20:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
COPY --from=build /root/.cargo/bin/homepage /usr/local/bin/homepage
|
2024-02-25 13:20:06 +01:00
|
|
|
|
|
|
|
COPY assets ./assets
|
|
|
|
|
2024-02-25 19:05:26 +01:00
|
|
|
# Copy CSS generated by Tailwind
|
|
|
|
COPY --from=build /usr/src/homepage/index.css assets/
|
|
|
|
|
|
|
|
COPY services.toml .
|
|
|
|
|
2024-02-25 13:20:06 +01:00
|
|
|
ENTRYPOINT ["homepage"]
|