homepage/Dockerfile
2024-02-25 13:20:06 +01:00

47 lines
715 B
Docker

# Build image
FROM docker.io/rust:alpine AS build
RUN apk add --no-cache musl-dev
WORKDIR /usr/src
# Create blank project
RUN cargo new homepage
WORKDIR /usr/src/homepage
COPY Cargo.* .
# Dummy build to cache dependencies
RUN cargo build --release
COPY src ./src
COPY templates ./templates
# Build the actual app
RUN touch src/main.rs && \
cargo build --release
# 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 /usr/src/homepage/target/release/homepage /usr/local/bin/homepage
COPY assets ./assets
ENTRYPOINT ["homepage"]