into-the-kosmos-generador/Dockerfile

42 lines
1.1 KiB
Docker
Raw Permalink Normal View History

2023-03-10 15:56:42 +01:00
################################################################################
## 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 . ./
2023-03-16 11:35:13 +01:00
# 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" \
2023-03-10 15:56:42 +01:00
&& 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"]