2017-10-13 11:13:10 +00:00
|
|
|
# -*- mode: dockerfile -*-
|
|
|
|
#
|
|
|
|
# An example Dockerfile showing how to build a Rust executable using this
|
|
|
|
# image, and deploy it with a tiny Alpine Linux container.
|
|
|
|
|
2019-04-27 12:51:12 +00:00
|
|
|
# You can override this `--build-arg BASE_IMAGE=...` to use different
|
|
|
|
# version of Rust or OpenSSL.
|
|
|
|
ARG BASE_IMAGE=ekidd/rust-musl-builder:latest
|
|
|
|
|
2017-10-13 11:13:10 +00:00
|
|
|
# Our first FROM statement declares the build environment.
|
2019-04-27 12:51:12 +00:00
|
|
|
FROM ${BASE_IMAGE} AS builder
|
2017-10-13 11:13:10 +00:00
|
|
|
|
2017-10-24 12:40:12 +00:00
|
|
|
# Add our source code.
|
|
|
|
ADD . ./
|
2017-10-13 11:13:10 +00:00
|
|
|
|
2017-10-24 12:40:12 +00:00
|
|
|
# Fix permissions on source code.
|
|
|
|
RUN sudo chown -R rust:rust /home/rust
|
2017-10-13 11:13:10 +00:00
|
|
|
|
|
|
|
# Build our application.
|
|
|
|
RUN cargo build --release
|
|
|
|
|
2017-10-24 12:40:12 +00:00
|
|
|
# Now, we need to build our _real_ Docker container, copying in `using-diesel`.
|
2017-10-13 11:13:10 +00:00
|
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
COPY --from=builder \
|
2017-10-24 12:40:12 +00:00
|
|
|
/home/rust/src/target/x86_64-unknown-linux-musl/release/using-diesel \
|
2017-10-13 11:13:10 +00:00
|
|
|
/usr/local/bin/
|
2017-10-24 12:40:12 +00:00
|
|
|
CMD /usr/local/bin/using-diesel
|