Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional embedding cardano cli in docker image #1789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/test-docker-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ on:
on it otherwise no binary would be available leading to the failure of this workflow.
required: true
type: string
embed_cardano_cli:
description: |
Embed Cardano-cli in the Docker image.
Only needed if you want to use cardano-cli chain observer.
required: true
type: boolean
default: false
cardano_bin_url:
description: The url of the archive of the Cardano binaries
required: true
Expand Down Expand Up @@ -90,6 +97,8 @@ jobs:
with:
context: ${{ env.CONTEXT }}
file: ${{ env.DOCKER_FILE }}
build-args: CARDANO_BIN_URL=${{ inputs.cardano_bin_url }}
build-args: |
EMBED-CARDANO-CLI=${{ inputs.embed_cardano_cli && 1 || 0 }}
CARDANO_BIN_URL=${{ inputs.cardano_bin_url }}
push: ${{ inputs.dry_run == false }}
tags: ${{ steps.meta.outputs.tags }}
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/runbook/test-docker-distribution/img/run-workflow-form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.5.30"
version = "0.5.31"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
22 changes: 15 additions & 7 deletions mithril-aggregator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ WORKDIR /app
COPY . .

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

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

# Build the binary
RUN cargo build --release -p mithril-aggregator
RUN cargo build --release --bin mithril-aggregator
RUN /app/target/release/mithril-aggregator --version

###############################
Expand All @@ -34,6 +37,7 @@ FROM debian:11-slim
# Args
ARG CARDANO_NODE_VERSION=8.9.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/*
Expand All @@ -48,10 +52,14 @@ COPY --from=rustbuilder /app/target/release/mithril-aggregator /app/bin/mithril-
COPY --from=rustbuilder /app/mithril-aggregator/config /app/config

# Install cardano-cli
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL
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)
RUN /app/bin/cardano-cli --version
RUN rm -f cardano-bin.tar.gz
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/
Expand Down
11 changes: 8 additions & 3 deletions mithril-aggregator/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget && a
# Install cardano-cli
ARG CARDANO_NODE_VERSION=8.9.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
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
ARG EMBED-CARDANO-CLI=0
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
&& rm -f cardano-bin.tar.gz \
&& chmod a+x /app/bin/cardano-cli; \
fi

# Copy the executable
COPY mithril-aggregator/mithril-aggregator /app/bin/mithril-aggregator
Expand All @@ -29,7 +34,7 @@ COPY mithril-aggregator/config /app/config

#Workdir
WORKDIR /app/
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-aggregator && chmod a+x /app/bin/cardano-cli
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-aggregator
jpraynaud marked this conversation as resolved.
Show resolved Hide resolved

# Use an unprivileged user
USER appuser
Expand Down
2 changes: 1 addition & 1 deletion mithril-signer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-signer"
version = "0.2.153"
version = "0.2.154"
description = "A Mithril Signer"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
13 changes: 9 additions & 4 deletions mithril-signer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ FROM debian:11-slim
# Args
ARG CARDANO_NODE_VERSION=8.9.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/*
Expand All @@ -49,10 +50,14 @@ COPY --from=rustbuilder /app/target/release/mithril-signer /app/bin/mithril-sign
COPY --from=rustbuilder /app/mithril-signer/config /app/config

# Install cardano-cli
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL
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)
RUN /app/bin/cardano-cli --version
RUN rm -f cardano-bin.tar.gz
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/
Expand Down
12 changes: 9 additions & 3 deletions mithril-signer/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget && a
# Install cardano-cli
ARG CARDANO_NODE_VERSION=8.9.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
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
ARG EMBED-CARDANO-CLI=0
# 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
&& rm -f cardano-bin.tar.gz \
&& chmod a+x /app/bin/cardano-cli; \
fi

# Copy the executable
COPY mithril-signer/mithril-signer /app/bin/mithril-signer
Expand All @@ -29,7 +35,7 @@ COPY mithril-signer/config /app/config

# Workdir
WORKDIR /app/
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-signer && chmod a+x /app/bin/cardano-cli
RUN chown -R appuser /app/ && chmod a+x /app/bin/mithril-signer
jpraynaud marked this conversation as resolved.
Show resolved Hide resolved

# Use an unprivileged user
USER appuser
Expand Down
Loading