Skip to content

Commit

Permalink
build docker accordingly to deb_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Oct 17, 2023
1 parent 9b09e6e commit 2c057b7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
12 changes: 11 additions & 1 deletion dockerfiles/Dockerfile-mina-archive
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ FROM ${image}
ARG deb_version
ARG deb_codename=bullseye
ARG deb_release=unstable
ARG deb_profile

# if --build-arg deb_profile is defined, add hypen at beginning.
ENV SUFFIX=${deb_profile:+-${deb_profile}}
# construct mina debian package name based on network and suffix.
# possible values:
# - mina-archive
# - mina-archive-lightnet etc.
ENV MINA_DEB=mina-archive${SUFFIX}

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND noninteractive
RUN echo "Building image with version $deb_codename $deb_release $deb_version"

Expand Down Expand Up @@ -38,7 +48,7 @@ RUN mkdir /healthcheck && curl https://raw.githubusercontent.com/MinaProtocol/mi
# archive-node package
RUN echo "deb [trusted=yes] http://packages.o1test.net $deb_codename $deb_release" > /etc/apt/sources.list.d/o1.list \
&& apt-get update --quiet --yes \
&& apt-get install --quiet --yes "mina-archive=$deb_version" \
&& apt-get install --quiet --yes "${MINA_DEB}=$deb_version" \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/usr/bin/dumb-init", "/entrypoint.sh"]
11 changes: 10 additions & 1 deletion dockerfiles/Dockerfile-mina-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ ARG deb_version
ARG deb_release=unstable
ARG deb_codename=bullseye
ARG network=mainnet
ARG deb_profile

# if --build-arg deb_profile is defined, add hypen at beginning.
ENV SUFFIX=${deb_profile:+-${deb_profile}}
# construct mina debian package name based on network and suffix.
# possible values:
# - mina-berkeley
# - mina-berkeley-lightnet etc.
ENV MINA_DEB=mina-${network}${SUFFIX}

ENV DEBIAN_FRONTEND noninteractive

Expand Down Expand Up @@ -59,7 +68,7 @@ ENV USE_GKE_GCLOUD_AUTH_PLUGIN=True
RUN echo "Building image with version $deb_version from repo $deb_release $deb_codename for network $network" \
&& echo "deb [trusted=yes] http://packages.o1test.net $deb_codename $deb_release" > /etc/apt/sources.list.d/o1.list \
&& apt-get update --quiet --yes \
&& apt-get install --quiet --yes --allow-downgrades "mina-$network=$deb_version" \
&& apt-get install --quiet --yes --allow-downgrades "${MINA_DEB}=$deb_version" \
&& rm -rf /var/lib/apt/lists/*


Expand Down
13 changes: 5 additions & 8 deletions scripts/release-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ case "${DEB_CODENAME##*=}" in
esac
IMAGE="--build-arg image=${IMAGE}"

# Determina suffix for mina name. To preserve backward compatibility devnet profile won't have any suffix.
# For others profiles we are adding suffix. For example '-lightnet'
# Determina profile for mina name. To preserve backward compatibility devnet profile is default.
case "${DEB_PROFILE}" in
devnet)
SERVICE_SUFFIX=""
DEB_PROFILE=""
;;
*)
SERVICE_SUFFIX="-${DEB_PROFILE}"
DEB_PROFILE="--build-arg deb_profile=${DEB_PROFILE}"
;;
esac

Expand All @@ -85,7 +84,6 @@ case "${SERVICE}" in
mina-archive)
DOCKERFILE_PATH="dockerfiles/Dockerfile-mina-archive"
DOCKER_CONTEXT="dockerfiles/"
SERVICE=${SERVICE}${SERVICE_SUFFIX}
;;
bot)
DOCKERFILE_PATH="frontend/bot/Dockerfile"
Expand All @@ -95,7 +93,6 @@ mina-daemon)
DOCKERFILE_PATH="dockerfiles/Dockerfile-mina-daemon"
DOCKER_CONTEXT="dockerfiles/"
VERSION="${VERSION}-${NETWORK##*=}"
SERVICE=${SERVICE}${SERVICE_SUFFIX}
;;
mina-toolchain)
DOCKERFILE_PATH="dockerfiles/stages/1-build-deps dockerfiles/stages/2-opam-deps dockerfiles/stages/3-toolchain"
Expand Down Expand Up @@ -150,9 +147,9 @@ HASHTAG="${DOCKER_REGISTRY}/${SERVICE}:${GITHASH}-${DEB_CODENAME##*=}-${NETWORK#
# If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build
extra_build_args=$(echo ${EXTRA} | tr -d '"')
if [[ -z "${DOCKER_CONTEXT}" ]]; then
cat $DOCKERFILE_PATH | docker build $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $BRANCH $REPO $extra_build_args -t "$TAG" -
cat $DOCKERFILE_PATH | docker build $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DEB_PROFILE $BRANCH $REPO $extra_build_args -t "$TAG" -
else
docker build $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $BRANCH $REPO $extra_build_args $DOCKER_CONTEXT -t "$TAG" -f $DOCKERFILE_PATH
docker build $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DEB_PROFILE $BRANCH $REPO $extra_build_args $DOCKER_CONTEXT -t "$TAG" -f $DOCKERFILE_PATH
fi

if [[ -z "$NOUPLOAD" ]] || [[ "$NOUPLOAD" -eq 0 ]]; then
Expand Down

0 comments on commit 2c057b7

Please sign in to comment.