fej/Dockerfile

35 lines
800 B
Docker
Raw Normal View History

2021-03-13 11:53:33 +01:00
FROM rust:alpine AS builder
# Switch to the nightly build
RUN rustup default nightly
2021-03-05 20:40:49 +01:00
WORKDIR /usr/src/app
2021-03-13 11:53:33 +01:00
# Install build dependencies & create a new dummy project
# that we use as a build cache
RUN apk update && \
apk add --no-cache openssl openssl-dev musl-dev && \
cargo init --bin
# Build the dependencies
# This is done separately to reduce average compile time
# Afterwards, we remove the dummy src directory
COPY Cargo.toml Cargo.lock .
RUN cargo build --release && \
rm src/*.rs
# Now, we build our own source code
COPY src/ ./src
RUN cargo install --path .
2021-03-05 20:40:49 +01:00
2021-03-13 11:53:33 +01:00
# Now, we create the actual image
FROM alpine:latest
2021-03-05 20:40:49 +01:00
2021-03-13 10:41:44 +01:00
# Install dependencies
2021-03-13 11:53:33 +01:00
RUN apk update && apk add --no-cache openssl
2021-03-13 10:41:44 +01:00
2021-03-05 20:40:49 +01:00
COPY --from=builder /usr/local/cargo/bin/rust-api /usr/local/bin/rust-api
CMD ["rust-api"]