-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile.bolik-api
50 lines (37 loc) · 1.32 KB
/
Dockerfile.bolik-api
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
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR app
# Compute recipe.json (our dependencies)
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Build
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN apt-get update
# OpenSSL dependencies
RUN apt-get install -y pkg-config libssl-dev make
# Protobuf
# RUN apt-get install -y protobuf-compiler libprotobuf-dev
# Debian bullseye comes with too old protoc version
RUN apt-get install -y curl unzip \
&& mkdir -p /tmp/protoc \
&& cd /tmp/protoc \
&& curl -Lo protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-x86_64.zip \
&& unzip protoc.zip \
&& chmod +x bin/protoc \
&& cp bin/protoc /usr/bin/protoc
RUN protoc --version
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cd bolik_server && cargo build --release
# Runtime
FROM debian:bullseye-slim AS runtime
RUN apt-get update
RUN apt-get -y install sqlite3 ca-certificates fuse
WORKDIR app
ADD litefs.yml /etc/litefs.yml
COPY --from=flyio/litefs:0.3 /usr/local/bin/litefs /usr/local/bin/litefs
COPY --from=builder /app/target/release/bolik_server /usr/local/bin/bolik_server
CMD litefs mount -- bolik_server