Skip to content

Commit

Permalink
use env variable for apt non-cache settings, revert split into severa…
Browse files Browse the repository at this point in the history
…l RUN commands

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
  • Loading branch information
daniellehrner committed Apr 30, 2024
1 parent 9431b10 commit a2fd185
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.
33 changes: 13 additions & 20 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@

FROM ubuntu:23.10
ARG VERSION="dev"
ENV NO_PROXY_CACHE="-o Acquire::BrokenProxy=true -o Acquire::http::No-Cache=true -o Acquire::http::Pipeline-Depth=0"

# Clean apt cache
RUN apt-get clean
RUN rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/*
RUN rm -rf /var/lib/apt/lists/*

# Update and install dependencies without using any cache
RUN apt-get update -o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0"
RUN apt-get install -o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0" \
--no-install-recommends -q --assume-yes openjdk-21-jre-headless=21* libjemalloc-dev=5.* adduser=3*

# Ubuntu 23.10 comes with an "ubuntu" user with uid 1000. We need 1000 for besu.
RUN userdel ubuntu 2>/dev/null || true && rm -rf /home/ubuntu

# Ensure we use a stable UID for besu, as file permissions are tied to UIDs.
RUN adduser --uid 1000 --disabled-password --gecos "" --home /opt/besu besu
RUN chown besu:besu /opt/besu
RUN chmod 0755 /opt/besu
RUN apt-get clean && \
rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/* && \
rm -rf /var/lib/apt/lists/* && \
# Update and install dependencies without using any cache
apt-get update $NO_PROXY_CACHE && \
apt-get install $NO_PROXY_CACHE --no-install-recommends -q --assume-yes openjdk-21-jre-headless=21* libjemalloc-dev=5.* adduser=3* && \
# Ubuntu 23.10 comes with an "ubuntu" user with uid 1000. We need 1000 for besu.
userdel ubuntu 2>/dev/null || true && rm -rf /home/ubuntu && \
# Ensure we use a stable UID for besu, as file permissions are tied to UIDs.
adduser --uid 1000 --disabled-password --gecos "" --home /opt/besu besu && \
chown besu:besu /opt/besu && \
chmod 0755 /opt/besu

USER besu
WORKDIR /opt/besu
Expand Down
29 changes: 11 additions & 18 deletions ethereum/evmtool/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@

FROM ubuntu:22.04
ARG VERSION="dev"
ENV NO_PROXY_CACHE="-o Acquire::BrokenProxy=true -o Acquire::http::No-Cache=true -o Acquire::http::Pipeline-Depth=0"

# Clean apt cache
RUN apt-get clean
RUN rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/*
RUN rm -rf /var/lib/apt/lists/*

# Update and install dependencies without using any cache
RUN apt-get update -o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0"
RUN apt-get install -o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0" --no-install-recommends -q --assume-yes ca-certificates-java=20190909*
RUN apt-get install -o Acquire::BrokenProxy="true" \
-o Acquire::http::No-Cache="true" \
-o Acquire::http::Pipeline-Depth="0" --no-install-recommends -q --assume-yes openjdk-17-jre-headless=17*

# Creating a user for besu
RUN adduser --disabled-password --gecos "" --home /opt/besu besu
RUN chown besu:besu /opt/besu
RUN apt-get clean && \
rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/* && \
rm -rf /var/lib/apt/lists/* && \
# Update and install dependencies without using any cache
apt-get update $NO_PROXY_CACHE && \
apt-get install $NO_PROXY_CACHE --no-install-recommends -q --assume-yes ca-certificates-java=20190909* && \
apt-get install $NO_PROXY_CACHE --no-install-recommends -q --assume-yes openjdk-17-jre-headless=17* && \
# Creating a user for besu
adduser --disabled-password --gecos "" --home /opt/besu besu && \
chown besu:besu /opt/besu

USER besu
WORKDIR /opt/besu-evmtool
Expand Down

0 comments on commit a2fd185

Please sign in to comment.