-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
28 lines (26 loc) · 1.15 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
FROM rust:alpine as builder
# Workaround "cannot find crti.o"
RUN apk add --no-cache musl-dev
WORKDIR /app
# First, only copy over the Cargo manifests, and do a build with a dummy
# main.rs. This way, Docker can cache all of this, and only actually download
# and build those depepndencies once. This is nice, because otherwise it's
# quite slow.
COPY Cargo.toml Cargo.lock .
RUN mkdir src && echo "fn main() { }" > src/main.rs
RUN cargo build --release
RUN rm -r src/
# The above should get cached; but the below steps will be executed each
# time you change the source code and do 'docker build'.
COPY . .
RUN cargo build --release
RUN strip target/release/tidy
FROM scratch
COPY --from=builder /app/target/release/tidy /bin/tidy
ENTRYPOINT ["/bin/tidy"]
# Add some metadata about the image, for extra neatness.
LABEL org.opencontainers.image.title="tidy" \
org.opencontainers.image.description="A command-line tool for combining and cleaning large word list files" \
org.opencontainers.image.url="https://github.com/sts10/tidy" \
org.opencontainers.image.authors="Sam Schlinkert <sschlinkert@gmail.com" \
org.opencontainers.image.licenses="MIT"