-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.rust
44 lines (34 loc) · 1.94 KB
/
Dockerfile.rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# nightly rust image
ARG RUST_IMAGE=rustlang/rust@sha256:722a946b19afc1aa32cda11978b1a07426aed06737bf258bec244c0640d50630
ARG BUILT_IMAGE=debian:buster-slim
###
# Development
FROM ${RUST_IMAGE} as sqlx_build
RUN cargo install --git https://github.com/launchbadge/sqlx.git --rev a9fb19b37da0e77fd891b8a2358733c563115a5c cargo-sqlx
FROM ${RUST_IMAGE} as sqlx
COPY --from=sqlx_build /usr/local/cargo/bin/sqlx /usr/local/bin/sqlx
FROM ${RUST_IMAGE} as watcher_build
ARG SYSTEMFD_VERS=0.3.0
RUN cargo install --version ${SYSTEMFD_VERS} systemfd
ARG SCCACHE_VERS=0.2.13
ARG CARGO_WATCH_VERS=v7.3.0
ADD https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERS}/sccache-${SCCACHE_VERS}-x86_64-unknown-linux-musl.tar.gz /tmp/sccache.tar.gz
ADD https://github.com/passcod/cargo-watch/releases/download/${CARGO_WATCH_VERS}/cargo-watch-${CARGO_WATCH_VERS}-x86_64-unknown-linux-musl.tar.xz /tmp/cargo-watch.tar.xz
RUN tar -xzf /tmp/sccache.tar.gz -C /tmp/ && mv /tmp/sccache-${SCCACHE_VERS}-x86_64-unknown-linux-musl/sccache /usr/local/cargo/bin/sccache
RUN tar -xf /tmp/cargo-watch.tar.xz -C /tmp/ && mv /tmp/cargo-watch-${CARGO_WATCH_VERS}-x86_64-unknown-linux-musl/cargo-watch /usr/local/cargo/bin/cargo-watch
FROM ${RUST_IMAGE} as watcher
WORKDIR /app
COPY --from=watcher_build /usr/local/cargo/bin/systemfd /usr/local/bin/systemfd
COPY --from=watcher_build /usr/local/cargo/bin/cargo-watch /usr/local/bin/cargo-watch
COPY --from=sqlx /usr/local/bin/sqlx /usr/local/bin/sqlx
RUN rustup component add clippy
RUN apt update && apt install rsync -y && rm -rf /var/lib/apt/lists/*
CMD ["systemfd", "--no-pid", "-s", "http::0.0.0.0:8000", "--", "cargo", "watch", "--watch", "src", "--exec", "run"]
###
# Building the watcher image
# docker build --target watcher --tag ncrmro/rust:watcher -f Dockerfile.rust .
# docker push ncrmro/rust:watcher
###
# Building the sqlx image
# docker build --target sqlx --tag ncrmro/rust:sqlx -f Dockerfile.rust .
# docker push ncrmro/rust:sqlx