Skip to content

Commit

Permalink
Added "install_packages" helper script, kindly provided by bitnami/mi…
Browse files Browse the repository at this point in the history
…nideb.

# Conflicts:
#	Dockerfile
  • Loading branch information
danieltrick committed Sep 16, 2024
1 parent 71dda83 commit e6d95b4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
48 changes: 25 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ FROM $DEBIAN_VERS AS build
ARG RUST_VERSION=nightly-2024-09-10

# Set up environment
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/opt/rust/cargo
ENV RUSTUP_HOME=/opt/rust/rustup
ENV CARGO_HOME=/opt/rust/cargo

# Provide the 'install_packages' tool
COPY src/install_packages.sh /usr/sbin/install_packages

# Install build dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
rdfind \
&& rm -r /var/lib/apt/lists /var/cache/apt/archives
RUN install_packages \
ca-certificates \
curl \
rdfind

# Install Rust
RUN curl https://sh.rustup.rs -sSf | \
Expand All @@ -33,18 +33,25 @@ RUN curl https://sh.rustup.rs -sSf | \
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FROM $DEBIAN_VERS

ENV DEBIAN_FRONTEND=noninteractive
# Set up environment
ENV RUSTUP_HOME=/opt/rust/rustup
ENV CARGO_HOME=/opt/rust/cargo
ENV CARGO_TARGET_DIR=/var/tmp/rust/target

# Provide the 'install_packages' tool
COPY --from=build /usr/sbin/install_packages /usr/sbin/

# Copy Rust/Cargo files
COPY --from=build /opt/rust/ /opt/rust/

# Install runtime dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
libclang-dev \
libtss2-dev \
pkg-config \
uuid-dev \
&& rm -r /var/lib/apt/lists /var/cache/apt/archives
RUN install_packages \
ca-certificates \
gcc \
libclang-dev \
libtss2-dev \
pkg-config \
uuid-dev

# Copy Rust/Cargo files
COPY --from=build /opt/rust/ /opt/rust/
Expand All @@ -55,11 +62,6 @@ COPY bin/entry-point.sh /opt/rust/entry-point.sh
# Copy example project
COPY src/example/ /var/opt/rust/src/

# Set up environment
ENV RUSTUP_HOME=/opt/rust/rustup
ENV CARGO_HOME=/opt/rust/cargo
ENV CARGO_TARGET_DIR=/var/tmp/rust/target

# Working directory
WORKDIR /var/opt/rust/src

Expand Down
24 changes: 24 additions & 0 deletions src/install_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -e
set -u
export DEBIAN_FRONTEND=noninteractive
n=0
max=2
until [ $n -gt $max ]; do
set +e
(
apt-get update -qq &&
apt-get install -y --no-install-recommends "$@"
)
CODE=$?
set -e
if [ $CODE -eq 0 ]; then
break
fi
if [ $n -eq $max ]; then
exit $CODE
fi
echo "apt failed, retrying"
n=$(($n + 1))
done
rm -r /var/lib/apt/lists /var/cache/apt/archives

0 comments on commit e6d95b4

Please sign in to comment.