-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
executable file
·43 lines (30 loc) · 974 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM rust:1-alpine3.12 as build
# alpine needs this, otherwise we get an error when compiling rand v0.7.3
RUN apk add --no-cache musl-dev
RUN USER=root cargo new --bin nametag
WORKDIR /nametag
# copy manifests
COPY Cargo.lock Cargo.lock
COPY Cargo.toml Cargo.toml
# cache your dependencies
RUN cargo build --release \
&& rm src/*.rs
# copy source tree
COPY . .
# build for release
RUN rm -f target/release/deps/nametag \
&& cargo build --release \
&& cargo install --path .
# runner stage to decrease image size
FROM alpine:latest
WORKDIR /nametag
# copy the build artifact from the build stage
COPY --from=build /nametag/target/release/nametag /nametag
# copy word lists
COPY --from=build /nametag/word-lists /nametag/word-lists
# create user/group to run instead of sudo
RUN addgroup -g 1000 nametaggroup \
&& adduser -D -s /bin/sh -u 1000 -G nametaggroup nametaguser \
&& chown -R nametaguser:nametaggroup /nametag
USER nametaguser
CMD ["/bin/sh"]