49 lines
1.5 KiB
Docker

FROM docker.io/library/rust:1-alpine AS chef
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static git pkgconf
RUN cargo install cargo-chef
RUN cargo install trunk
RUN rustup target add wasm32-unknown-unknown
WORKDIR /app
FROM chef AS builder-peazyrsa
RUN cargo install --git https://gitea.b4tman.ru/b4tman/peazyrsa --tag v0.1.0
FROM chef AS planner-peasyweb
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder-peasyweb
COPY --from=planner-peasyweb /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ENV API_BASE_URL="/api/v1"
RUN cargo build -p peazyweb-backend --release
WORKDIR /app/frontend
RUN trunk build --release --public-url "/frontend"
WORKDIR /app
FROM docker.io/library/alpine:3.21 AS runtime
RUN apk add --no-cache openssl libssl3 libcrypto3
RUN mkdir -p /app/frontend
RUN mkdir /data
WORKDIR /app
COPY --from=builder-peazyrsa /usr/local/cargo/bin/peazyrsa /usr/local/bin/peazyrsa
COPY --from=builder-peasyweb /app/target/release/peazyweb-backend /usr/local/bin/peazyweb-backend
COPY --from=builder-peasyweb /app/frontend/dist/ /app/frontend
VOLUME [ "/data" ]
ENV GENERATION_BASE_DIRECTORY="/data"
ENV GENERATION_BIN="/usr/local/bin/peazyrsa"
ENV USE_OPENSSL="yes"
ENV OPENSSL_BIN="/usr/bin/openssl"
ENV FRONTEND_BASE="/app/frontend"
ENV ROCKET_ADDRESS="0.0.0.0"
ENV ROCKET_PORT=80
EXPOSE 80
ENTRYPOINT ["/usr/local/bin/peazyweb-backend"]