-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (30 loc) · 1.17 KB
/
Dockerfile
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
FROM rust:1-slim-buster as builder
RUN apt-get update && apt-get install -y build-essential pkg-config openssl libssl-dev
RUN groupadd -g 1000 -r bridge \
&& useradd -r -g bridge -u 1000 bridge \
&& mkdir -p /home/bridge \
&& chown -R bridge:bridge /home/bridge
# Build dummy main with the project's Cargo lock and toml
# This is a docker trick in order to avoid downloading and building
# dependencies when lock and toml is not modified.
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir src \
&& echo "fn main() {print!(\"Dummy main\");} // dummy file" > src/main.rs \
&& set -x && cargo build --release \
&& set -x && rm target/release/deps/publish_amqp_changefeed*
# Now add the rest of the project and build the real main
COPY src ./src
RUN set -x \
&& cargo build --release \
&& mkdir -p /build-out \
&& set -x \
&& cp target/release/publish_amqp_changefeed /build-out/
# Create a minimal docker image
FROM debian:buster-slim
RUN apt-get update && apt-get install -y libssl-dev
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /build-out/publish_amqp_changefeed /home/bridge/
USER bridge
WORKDIR /home/bridge
CMD ["./publish_amqp_changefeed"]