# we use thc for healthchecks FROM codeberg.org/gigirassy/thc:latest AS thc # alpine for static binaries FROM rust:alpine AS build # workdir, copy. WORKDIR /src COPY . . # to make the binary as tiny as possible, we'll use the nightly toolchain so we can use panic=immediate-abort and remove debug/location stuff RUN rustup component add rust-src --toolchain nightly # build RUN RUSTFLAGS="-Copt-level=z -Zfmt-debug=none -Zlocation-detail=none -Ctarget-feature=+crt-static" cargo +nightly install --path=. --root /tmp -Z build-std=std -Z build-std-features="optimize_for_size" # scratch runtime for security FROM scratch # "nobody" user for security USER 65535:65535 # copy binary into path COPY --from=build --chown=65535:65535 /tmp/bin/teletraan /teletraan COPY --from=thc /thc /thc # configure thc ENV THC_PORT=3000 \ THC_PATH=/ # data workdir. this allows using teletraan as the base for images easily via simply ``COPY --from=build /app/dist .`` WORKDIR /data # expose EXPOSE 3000 # to run it and thc. the cmd is left free so people can serve single page apps with the -s flag ENTRYPOINT ["/teletraan"] CMD [""] HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=5 CMD ["/thc"]