-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (38 loc) · 1.99 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
#### The image base should be the same as in .gitlab-ci.yml
#### Second stage of the Dockerfile (below) should use the same base (rust:slim or it's parent)
FROM rust:1.54-slim as cargo-build
WORKDIR /usr/src/pod
#### Compile dependencies and cache them in a docker layer
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y libsqlcipher-dev && rm -rf /var/lib/apt/lists/*
RUN set -x && \
mkdir -p src && \
echo "fn main() {println!(\"broken\")}" > src/main.rs && \
mkdir -p benches && \
echo "" > benches/rusqlite_reconnection.rs && \
cargo build --release && \
rm src/main.rs && \
find target/release/ -type f -executable -maxdepth 1 -delete
#### After the dependencies are built, copy the sources and build the real thing.
COPY res/migrations res/migrations
COPY build.rs build.rs
COPY src src
COPY benches benches
RUN cargo build --release && mv target/release/pod ./ && rm -rf target
#### After Pod has been built, create a small docker image with just the Pod
FROM debian:buster-slim
COPY --from=cargo-build /usr/src/pod/pod pod
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y libsqlcipher-dev apt-transport-https ca-certificates curl software-properties-common gnupg2 \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
&& apt-get update && apt-get install -y docker-ce && rm -rf /var/lib/apt/lists/*
ARG use_kubernetes=false
RUN if [ "$use_kubernetes" = "true" ] ; then \
curl -LO https://storage.googleapis.com/kubernetes-release/release/"$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)"/bin/linux/amd64/kubectl \
&& chmod +x ./kubectl \
&& mv ./kubectl /usr/local/bin/kubectl ; fi
# Check that library versions match (sqlcipher, libc, etc)
RUN ./pod --version 1>/dev/null 2>&1
EXPOSE 3030
CMD ["./pod"]