forked from input-output-hk/mithril
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (53 loc) · 2.22 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
###############################
# STEP 1: build rust executable
###############################
FROM rust:bullseye AS rustbuilder
# Create appuser
RUN adduser --no-create-home --disabled-password appuser
# Set workdir
WORKDIR /app
# Copy local dependencies
COPY . .
# Build the app using a dummy main in order to cache dependencies
RUN mv /app/mithril-signer /app/mithril-signer.1 && mkdir -p /app/mithril-signer/src
COPY mithril-signer/Cargo.toml /app/mithril-signer/
RUN echo "fn main () {}" > /app/mithril-signer/src/main.rs
RUN cargo build --release -p mithril-signer --manifest-path /app/mithril-signer/Cargo.toml
# Rollback the rest of the files into the container
RUN rm -rf /app/mithril-signer && mv /app/mithril-signer.1 /app/mithril-signer
COPY ./mithril-signer/src/main.rs /app/mithril-signer/src/
# Build the binary
RUN cargo build --release -p mithril-signer
RUN /app/target/release/mithril-signer --version
###############################
# STEP 2: build a small image
###############################
FROM debian:11-slim
# Args
ARG CARDANO_NODE_VERSION=9.1.0
ARG CARDANO_BIN_URL=https://github.com/input-output-hk/cardano-node/releases/download/$CARDANO_NODE_VERSION/cardano-node-$CARDANO_NODE_VERSION-linux.tar.gz
ARG EMBED-CARDANO-CLI=0
# Upgrade
RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget sqlite3 && rm -rf /var/lib/apt/lists/*
# Import the user and group files from the builder
COPY --from=rustbuilder /etc/passwd /etc/passwd
# Copy the executable
COPY --from=rustbuilder /app/target/release/mithril-signer /app/bin/mithril-signer
# Copy the config files
COPY --from=rustbuilder /app/mithril-signer/config /app/config
# Install cardano-cli
RUN if [ "$EMBED-CARDANO-CLI" = 1 ] ; then \
wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
&& mkdir -p /app/bin \
&& (tar xzf cardano-bin.tar.gz ./bin/cardano-cli && mv /bin/cardano-cli /app/bin) || (tar xzf cardano-bin.tar.gz ./cardano-cli && mv cardano-cli /app/bin) \
&& /app/bin/cardano-cli --version \
&& rm -f cardano-bin.tar.gz \
&& chmod a+x /app/bin/cardano-cli; \
fi
#Workdir
WORKDIR /app/
RUN chown -R appuser /app/
# Use an unprivileged user
USER appuser
# Run the executable
ENTRYPOINT ["/app/bin/mithril-signer", "-vvv"]