From 4bb244b7ca0f4cc16e73c064436b7f8d81e96953 Mon Sep 17 00:00:00 2001 From: michaelmartinez Date: Wed, 18 Sep 2024 17:21:55 -0700 Subject: [PATCH 1/2] allow for the bundling of Core package from apt "testing" pool ### What a new Dockerfile to install Core from the "testing" pool an update to the Makefile specifically for this case ### Why adding support for the "testing" pool to the Dockerfile would make the file more confusing to read, so I decided to use a separate Dockerfile ### Testing I will test this manually shortly ### Issue addressed by this PR https://github.com/stellar/ops/issues/3124 --- services/horizon/docker/Dockerfile | 1 + .../horizon/docker/Dockerfile.core-testing | 19 +++++++++++++++++++ services/horizon/docker/Makefile | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 services/horizon/docker/Dockerfile.core-testing diff --git a/services/horizon/docker/Dockerfile b/services/horizon/docker/Dockerfile index 3c090d203c..2d5c7a01a2 100644 --- a/services/horizon/docker/Dockerfile +++ b/services/horizon/docker/Dockerfile @@ -1,3 +1,4 @@ +# install Core from apt "stable" or "unstable" pool, and horizon from apt "testing" pool FROM ubuntu:focal ARG VERSION diff --git a/services/horizon/docker/Dockerfile.core-testing b/services/horizon/docker/Dockerfile.core-testing new file mode 100644 index 0000000000..c0d1dff8e6 --- /dev/null +++ b/services/horizon/docker/Dockerfile.core-testing @@ -0,0 +1,19 @@ +# install both horizon and core from apt "testing" pool +FROM ubuntu:focal + +ARG VERSION +ARG STELLAR_CORE_VERSION +ARG DEBIAN_FRONTEND=noninteractive +ARG ALLOW_CORE_UNSTABLE=no + +RUN apt-get update && apt-get install -y wget apt-transport-https gnupg2 && \ + wget -qO /etc/apt/trusted.gpg.d/SDF.asc https://apt.stellar.org/SDF.asc && \ + echo "deb https://apt.stellar.org focal testing" | tee -a /etc/apt/sources.list.d/SDF.list && \ + cat /etc/apt/sources.list.d/SDF.list && \ + apt-get update && \ + apt-cache madison stellar-core && eval "apt-get install -y stellar-core${STELLAR_CORE_VERSION+=$STELLAR_CORE_VERSION}" && \ + apt-cache madison stellar-horizon && apt-get install -y stellar-horizon=${VERSION} && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /var/log/*.log /var/log/*/*.log + +EXPOSE 8000 +ENTRYPOINT ["/usr/bin/stellar-horizon"] diff --git a/services/horizon/docker/Makefile b/services/horizon/docker/Makefile index 51ee19f2fe..16f6e2f831 100644 --- a/services/horizon/docker/Makefile +++ b/services/horizon/docker/Makefile @@ -5,6 +5,7 @@ BUILD_DATE := $(shell date -u +%FT%TZ) TAG ?= stellar/stellar-horizon:$(VERSION) +# build with Core from apt "stable" or "unstable", and horizon from apt "testing" docker-build: ifndef VERSION $(error VERSION environment variable must be set. For example VERSION=2.4.1-101 ) @@ -22,6 +23,22 @@ else -t $(TAG) . endif +# build Core and Horizon from apt "testing" +docker-build-core-testing: +ifndef VERSION + $(error VERSION environment variable must be set. For example VERSION=2.4.1-101 ) +endif +ifndef STELLAR_CORE_VERSION + $(SUDO) docker build --file ./Dockerfile.core-testing --pull $(DOCKER_OPTS) \ + --label org.opencontainers.image.created="$(BUILD_DATE)" \ + --build-arg VERSION=$(VERSION) -t $(TAG) . +else + $(SUDO) docker build --pull $(DOCKER_OPTS) \ + --label org.opencontainers.image.created="$(BUILD_DATE)" \ + --build-arg VERSION=$(VERSION) --build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) \ + -t $(TAG) . +endif + docker-push: ifndef TAG $(error Must set VERSION or TAG environment variable. For example VERSION=2.4.1-101 ) From 844f84702301b680e9f054c091e0923c37d281c9 Mon Sep 17 00:00:00 2001 From: michaelmartinez Date: Tue, 24 Sep 2024 12:07:57 -0700 Subject: [PATCH 2/2] add support to build horizon docker images from apt stable ### What build horizon docker image from core "stable" and horizon "stable" ### Why this is needed in order to support the new workflow described in the ticket ### Testing this has been tested and works with apt "testing" ### Issue addressed by this PR https://github.com/stellar/ops/issues/3124 --- services/horizon/docker/Dockerfile.stable | 18 ++++++++++++++++++ services/horizon/docker/Makefile | 16 ++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 services/horizon/docker/Dockerfile.stable diff --git a/services/horizon/docker/Dockerfile.stable b/services/horizon/docker/Dockerfile.stable new file mode 100644 index 0000000000..63f268873a --- /dev/null +++ b/services/horizon/docker/Dockerfile.stable @@ -0,0 +1,18 @@ +# install Core from apt "stable"and horizon from apt "stable" pool +FROM ubuntu:focal + +ARG VERSION +ARG STELLAR_CORE_VERSION +ARG DEBIAN_FRONTEND=noninteractive +ARG ALLOW_CORE_UNSTABLE=no + +RUN apt-get update && apt-get install -y wget apt-transport-https gnupg2 && \ + wget -qO /etc/apt/trusted.gpg.d/SDF.asc https://apt.stellar.org/SDF.asc && \ + echo "deb https://apt.stellar.org focal stable" | tee -a /etc/apt/sources.list.d/SDF.list && \ + cat /etc/apt/sources.list.d/SDF.list && \ + apt-get update && apt-cache madison stellar-core && eval "apt-get install -y stellar-core${STELLAR_CORE_VERSION+=$STELLAR_CORE_VERSION}" && \ + apt-cache madison stellar-horizon && apt-get install -y stellar-horizon=${VERSION} && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /var/log/*.log /var/log/*/*.log + +EXPOSE 8000 +ENTRYPOINT ["/usr/bin/stellar-horizon"] diff --git a/services/horizon/docker/Makefile b/services/horizon/docker/Makefile index 16f6e2f831..26d3c892d0 100644 --- a/services/horizon/docker/Makefile +++ b/services/horizon/docker/Makefile @@ -29,11 +29,23 @@ ifndef VERSION $(error VERSION environment variable must be set. For example VERSION=2.4.1-101 ) endif ifndef STELLAR_CORE_VERSION + $(error STELLAR_CORE_VERSION environment variable must be set. ) +else $(SUDO) docker build --file ./Dockerfile.core-testing --pull $(DOCKER_OPTS) \ --label org.opencontainers.image.created="$(BUILD_DATE)" \ - --build-arg VERSION=$(VERSION) -t $(TAG) . + --build-arg VERSION=$(VERSION) --build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) \ + -t $(TAG) . +endif + +# build Core and Horizon from apt "stable" +docker-build-core-stable: +ifndef VERSION + $(error VERSION environment variable must be set. For example VERSION=2.4.1-101 ) +endif +ifndef STELLAR_CORE_VERSION + $(error STELLAR_CORE_VERSION environment variable must be set. ) else - $(SUDO) docker build --pull $(DOCKER_OPTS) \ + $(SUDO) docker build --file ./Dockerfile.stable --pull $(DOCKER_OPTS) \ --label org.opencontainers.image.created="$(BUILD_DATE)" \ --build-arg VERSION=$(VERSION) --build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) \ -t $(TAG) .