# 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 # 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. the cmd is left free so people can serve single page apps with the -s flag ENTRYPOINT ["/teletraan"] CMD [""]