Automated docker build

This commit is contained in:
Arghyadip Chakraborty 2022-08-25 22:25:03 +05:30
parent f55a5eba96
commit 08871e15b6
3 changed files with 84 additions and 29 deletions

View file

@ -1,23 +1,27 @@
# latest rust will be used to build the binary
FROM rust:latest as builder
FROM rust:latest as build
# the temporary directory where we build
WORKDIR /usr/src/microbin
WORKDIR /app
# copy sources to /usr/src/microbin on the temporary container
COPY . .
# run release build
RUN cargo build --release
RUN \
DEBIAN_FRONTEND=noninteractive \
apt-get update &&\
apt-get -y install ca-certificates tzdata &&\
cargo build --release
# create final container using slim version of debian
FROM debian:buster-slim
FROM debian:bullseye-slim
# microbin will be in /usr/local/bin/microbin/
WORKDIR /usr/local/bin
WORKDIR /app
# copy built exacutable
COPY --from=builder /usr/src/microbin/target/release/microbin /usr/local/bin/microbin
COPY --from=build \
/usr/share/zoneinfo \
/usr/share/zoneinfo
COPY --from=build \
/etc/ssl/certs/ca-certificates.crt \
/etc/ssl/certs/ca-certificates.crt
COPY --from=build \
/app/target/release/microbin \
/usr/bin/microbin
# run the binary
CMD ["microbin"]
ENTRYPOINT ["microbin"]