This repository has been archived by the owner on Feb 11, 2024. It is now read-only.
generated from WalletConnect/rust-http-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
90 lines (76 loc) · 3.1 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
################################################################################
#
# Build args
#
################################################################################
ARG base="rust:buster"
ARG runtime="debian:buster-slim"
ARG bin="gilgamesh"
ARG version="unknown"
ARG sha="unknown"
ARG maintainer="WalletConnect"
ARG release=""
################################################################################
#
# Install cargo-chef
#
################################################################################
FROM ${base} AS chef
WORKDIR /app
RUN cargo install cargo-chef
################################################################################
#
# Generate recipe file
#
################################################################################
FROM chef AS plan
WORKDIR /app
COPY Cargo.lock Cargo.toml ./
COPY src ./src
RUN cargo chef prepare --recipe-path recipe.json
################################################################################
#
# Build the binary
#
################################################################################
FROM chef AS build
ARG release
ENV RELEASE=${release:+--release}
# This is a build requirement of `opentelemetry-otlp`. Once the new version
# is rolled out, which no longer requires the `protoc`, we'll be able to
# get rid of this.
RUN apt-get update \
&& apt-get install -y --no-install-recommends protobuf-compiler
WORKDIR /app
# Cache dependancies
COPY --from=plan /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json ${RELEASE}
# Build the local binary
COPY . .
RUN cargo build --bin gilgamesh ${RELEASE}
# Certificate file required to use TLS with AWS DocumentDB.
RUN wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
################################################################################
#
# Runtime image
#
################################################################################
FROM ${runtime} AS runtime
ARG bin
ARG version
ARG sha
ARG maintainer
ARG release
ARG binpath=${release:+release}
LABEL version=${version}
LABEL sha=${sha}
LABEL maintainer=${maintainer}
WORKDIR /app
COPY --from=build /app/target/${binpath:-debug}/gilgamesh /usr/local/bin/gilgamesh
COPY --from=build /app/rds-combined-ca-bundle.pem /app/rds-combined-ca-bundle.pem
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER 1001:1001
ENTRYPOINT ["/usr/local/bin/gilgamesh"]