Skip to content

Commit 4409ebb

Browse files
authored
Merge pull request input-output-hk#1789 from input-output-hk/sfa/1725/conditional_embedding_cardano_cli_in_docker_image
Conditional embedding cardano cli in docker image
2 parents ed03ede + 4e6e69f commit 4409ebb

File tree

9 files changed

+55
-22
lines changed

9 files changed

+55
-22
lines changed

.github/workflows/test-docker-distribution.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ on:
1414
on it otherwise no binary would be available leading to the failure of this workflow.
1515
required: true
1616
type: string
17+
embed_cardano_cli:
18+
description: |
19+
Embed Cardano-cli in the Docker image.
20+
Only needed if you want to use cardano-cli chain observer.
21+
required: true
22+
type: boolean
23+
default: false
1724
cardano_bin_url:
1825
description: The url of the archive of the Cardano binaries
1926
required: true
@@ -90,6 +97,8 @@ jobs:
9097
with:
9198
context: ${{ env.CONTEXT }}
9299
file: ${{ env.DOCKER_FILE }}
93-
build-args: CARDANO_BIN_URL=${{ inputs.cardano_bin_url }}
100+
build-args: |
101+
EMBED-CARDANO-CLI=${{ inputs.embed_cardano_cli && 1 || 0 }}
102+
CARDANO_BIN_URL=${{ inputs.cardano_bin_url }}
94103
push: ${{ inputs.dry_run == false }}
95104
tags: ${{ steps.meta.outputs.tags }}

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

mithril-aggregator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.5.30"
3+
version = "0.5.31"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/Dockerfile

+15-7
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ WORKDIR /app
1313
COPY . .
1414

1515
# Build the app using a dummy main in order to cache dependencies
16-
RUN mv /app/mithril-aggregator /app/mithril-aggregator.1 && mkdir -p /app/mithril-aggregator/src
16+
RUN mv /app/mithril-aggregator /app/mithril-aggregator.1 \
17+
&& mkdir -p /app/mithril-aggregator/src \
18+
&& mkdir -p /app/mithril-aggregator/benches
1719
COPY mithril-aggregator/Cargo.toml /app/mithril-aggregator/
20+
COPY mithril-aggregator/benches/* /app/mithril-aggregator/benches/
1821
RUN echo "fn main () {}" > /app/mithril-aggregator/src/main.rs
19-
RUN cargo build --release -p mithril-aggregator --manifest-path /app/mithril-aggregator/Cargo.toml
22+
RUN cargo build --release --bin mithril-aggregator --manifest-path /app/mithril-aggregator/Cargo.toml
2023

2124
# Rollback the rest of the files into the container
2225
RUN rm -rf /app/mithril-aggregator && mv /app/mithril-aggregator.1 /app/mithril-aggregator
2326
COPY ./mithril-aggregator/src/main.rs /app/mithril-aggregator/src/
2427

2528
# Build the binary
26-
RUN cargo build --release -p mithril-aggregator
29+
RUN cargo build --release --bin mithril-aggregator
2730
RUN /app/target/release/mithril-aggregator --version
2831

2932
###############################
@@ -34,6 +37,7 @@ FROM debian:11-slim
3437
# Args
3538
ARG CARDANO_NODE_VERSION=8.9.0
3639
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
40+
ARG EMBED-CARDANO-CLI=0
3741

3842
# Upgrade
3943
RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget sqlite3 && rm -rf /var/lib/apt/lists/*
@@ -48,10 +52,14 @@ COPY --from=rustbuilder /app/target/release/mithril-aggregator /app/bin/mithril-
4852
COPY --from=rustbuilder /app/mithril-aggregator/config /app/config
4953

5054
# Install cardano-cli
51-
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL
52-
RUN (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)
53-
RUN /app/bin/cardano-cli --version
54-
RUN rm -f cardano-bin.tar.gz
55+
RUN if [ "$EMBED-CARDANO-CLI" = 1 ] ; then \
56+
wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
57+
&& mkdir -p /app/bin \
58+
&& (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) \
59+
&& /app/bin/cardano-cli --version \
60+
&& rm -f cardano-bin.tar.gz \
61+
&& chmod a+x /app/bin/cardano-cli; \
62+
fi
5563

5664
#Workdir
5765
WORKDIR /app/

mithril-aggregator/Dockerfile.ci

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget && a
1616
# Install cardano-cli
1717
ARG CARDANO_NODE_VERSION=8.9.0
1818
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
19-
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
19+
ARG EMBED-CARDANO-CLI=0
20+
RUN if [ "$EMBED-CARDANO-CLI" = 1 ] ; then \
21+
wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
22+
&& mkdir -p /app/bin \
2023
&& (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) \
2124
&& /app/bin/cardano-cli --version \
22-
&& rm -f cardano-bin.tar.gz
25+
&& rm -f cardano-bin.tar.gz \
26+
&& chmod a+x /app/bin/cardano-cli; \
27+
fi
2328

2429
# Copy the executable
2530
COPY mithril-aggregator/mithril-aggregator /app/bin/mithril-aggregator
@@ -29,7 +34,7 @@ COPY mithril-aggregator/config /app/config
2934

3035
#Workdir
3136
WORKDIR /app/
32-
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-aggregator && chmod a+x /app/bin/cardano-cli
37+
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-aggregator
3338

3439
# Use an unprivileged user
3540
USER appuser

mithril-signer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-signer"
3-
version = "0.2.153"
3+
version = "0.2.154"
44
description = "A Mithril Signer"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-signer/Dockerfile

+9-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ FROM debian:11-slim
3535
# Args
3636
ARG CARDANO_NODE_VERSION=8.9.0
3737
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
38+
ARG EMBED-CARDANO-CLI=0
3839

3940
# Upgrade
4041
RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget sqlite3 && rm -rf /var/lib/apt/lists/*
@@ -49,10 +50,14 @@ COPY --from=rustbuilder /app/target/release/mithril-signer /app/bin/mithril-sign
4950
COPY --from=rustbuilder /app/mithril-signer/config /app/config
5051

5152
# Install cardano-cli
52-
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL
53-
RUN (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)
54-
RUN /app/bin/cardano-cli --version
55-
RUN rm -f cardano-bin.tar.gz
53+
RUN if [ "$EMBED-CARDANO-CLI" = 1 ] ; then \
54+
wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
55+
&& mkdir -p /app/bin \
56+
&& (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) \
57+
&& /app/bin/cardano-cli --version \
58+
&& rm -f cardano-bin.tar.gz \
59+
&& chmod a+x /app/bin/cardano-cli; \
60+
fi
5661

5762
#Workdir
5863
WORKDIR /app/

mithril-signer/Dockerfile.ci

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget && a
1616
# Install cardano-cli
1717
ARG CARDANO_NODE_VERSION=8.9.0
1818
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
19-
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
19+
ARG EMBED-CARDANO-CLI=0
20+
# Install cardano-cli
21+
RUN if [ "$EMBED-CARDANO-CLI" = 1 ] ; then \
22+
wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
23+
&& mkdir -p /app/bin \
2024
&& (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) \
2125
&& /app/bin/cardano-cli --version \
22-
&& rm -f cardano-bin.tar.gz
26+
&& rm -f cardano-bin.tar.gz \
27+
&& chmod a+x /app/bin/cardano-cli; \
28+
fi
2329

2430
# Copy the executable
2531
COPY mithril-signer/mithril-signer /app/bin/mithril-signer
@@ -29,7 +35,7 @@ COPY mithril-signer/config /app/config
2935

3036
# Workdir
3137
WORKDIR /app/
32-
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-signer && chmod a+x /app/bin/cardano-cli
38+
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-signer
3339

3440
# Use an unprivileged user
3541
USER appuser

0 commit comments

Comments
 (0)