################################################################################ ## BUILDER ################################################################################ FROM rust:slim as builder # para compilación estática sin libc ENV TARGET x86_64-unknown-linux-musl RUN rustup target add "$TARGET" # xeneracion do executable RUN USER=root mkdir ./itkg WORKDIR ./itkg ADD . ./ # caché: xenera unha capa de docker para os sucesivos builds RUN --mount=type=cache,target=/usr/local/cargo/registry \ cargo build --release --locked --target "$TARGET" \ && mv "target/$TARGET/release/itkg" . \ && strip itkg # usuario para execucion RUN groupadd app && useradd -g app app ################################################################################ ## RUNER ################################################################################ FROM scratch ARG APP=/app EXPOSE 3007 COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group COPY --from=builder --chown=app:app /itkg/itkg ${APP}/itkg COPY --from=builder --chown=app:app /itkg/templates/ ${APP}/templates/ USER app WORKDIR ${APP} CMD ["./itkg"]