-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
48 lines (36 loc) · 1.35 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
# We need to use the Rust build image, because
# we need the Rust compile and Cargo tooling
FROM clux/muslrust:stable as build
# Install cmake as it is not included in muslrust, but is needed by libssh2-sys
RUN apt-get update && apt-get install -y \
cmake \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Creates a dummy project used to grab dependencies
RUN USER=root cargo init --bin
# Copies over *only* your manifests
COPY ./Cargo.* ./
# Builds your dependencies and removes the
# fake source code from the dummy project
RUN cargo build --release
RUN rm src/*.rs
RUN rm target/x86_64-unknown-linux-musl/release/hogan
# Copies only your actual source code to
# avoid invalidating the cache at all
COPY ./src ./src
# Builds again, this time it'll just be
# your actual source files being built
RUN cargo build --release
FROM alpine:latest as certs
RUN apk --update add ca-certificates
# Create a new stage with a minimal image
# because we already have a binary built
FROM alpine:latest
RUN apk --no-cache add git openssh
# Copies standard SSL certs from the "build" stage
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# Copies the binary from the "build" stage
COPY --from=build /app/target/x86_64-unknown-linux-musl/release/hogan /bin/
# Configures the startup!
ENTRYPOINT ["/bin/hogan"]