forked from erikgrinaker/toydb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
27 lines (22 loc) · 870 Bytes
/
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
# Initial build
FROM rust:1.53-slim AS build
ARG TARGET=x86_64-unknown-linux-musl
RUN apt-get -q update && apt-get -q install -y musl-dev
RUN rustup target add $TARGET
# FIXME: cargo does not have an option to only build dependencies, so we build
# a dummy main.rs. See: https://github.com/rust-lang/cargo/issues/2644
WORKDIR /usr/src/toydb
COPY Cargo.toml Cargo.lock ./
RUN mkdir src \
&& echo "fn main() {}" >src/main.rs \
&& echo "fn main() {}" >build.rs
RUN cargo fetch --target=$TARGET
RUN cargo build --release --target=$TARGET \
&& rm -rf build.rs src target/$TARGET/release/toydb*
COPY . .
RUN cargo install --bin toydb --locked --offline --path . --target=$TARGET
# Runtime image
FROM alpine:3.14
COPY --from=build /usr/local/cargo/bin/toydb /usr/local/bin/toydb
COPY --from=build /usr/src/toydb/config/toydb.yaml /etc/toydb.yaml
CMD ["toydb"]