homepage/Dockerfile

48 lines
716 B
Docker
Raw Normal View History

2024-02-25 13:20:06 +01:00
# 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
2024-02-25 14:14:38 +01:00
COPY Cargo.* ./
2024-02-25 13:20:06 +01:00
# 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"]