Skip to content

Commit

Permalink
Add package-based soroban-rpc Dockerfile (#710)
Browse files Browse the repository at this point in the history
* Add package-based soroban-rpc Dockerfile

### What

This PR adds new soroban-rpc Dockerfile that uses official
SDF deb packages as source of stellar-soroban-rpc and stellar-core

### Why

This Dockerfile will allow us to reuse release packages.
It will also allow us to run more lighweight soroban-rpc deployments
than those using the stellar/quickstart image

* Address PR feedback

* specify amd64 platform explicitly as we currently only support amd64 core
* make STELLAR_CORE_VERSION required to avoid hardcoding versions in the files.
  We will provide version from a dropdown in the build job
* if soroban-rpc version is not provided read it from GitHub and install latest
  package matching the version

---------

Co-authored-by: Tsachi Herman <[email protected]>
  • Loading branch information
jacekn and tsachiherman authored Jun 22, 2023
1 parent db9aa07 commit 94af5fa
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/soroban-rpc/docker/Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:20.04
ARG STELLAR_CORE_VERSION
ENV STELLAR_CORE_VERSION=${STELLAR_CORE_VERSION:-*}
ARG SOROBAN_RPC_VERSION
ENV SOROBAN_RPC_VERSION=${SOROBAN_RPC_VERSION:-*}

ENV STELLAR_CORE_BINARY_PATH /usr/bin/stellar-core
ENV DEBIAN_FRONTEND=noninteractive

# ca-certificates are required to make tls connections
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl wget gnupg apt-utils gpg && \
curl -sSL https://apt.stellar.org/SDF.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/SDF.gpg && \
echo "deb https://apt.stellar.org focal stable" >/etc/apt/sources.list.d/SDF.list && \
echo "deb https://apt.stellar.org focal testing" >/etc/apt/sources.list.d/SDF-testing.list && \
echo "deb https://apt.stellar.org focal unstable" >/etc/apt/sources.list.d/SDF-unstable.list && \
apt-get update && \
apt-get install -y stellar-core=${STELLAR_CORE_VERSION} stellar-soroban-rpc=${SOROBAN_RPC_VERSION} && \
apt-get clean

ENTRYPOINT ["/usr/bin/stellar-soroban-rpc"]
34 changes: 34 additions & 0 deletions cmd/soroban-rpc/docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SUDO := $(shell docker version >/dev/null 2>&1 || echo "sudo")

# https://github.com/opencontainers/image-spec/blob/master/annotations.md
BUILD_DATE := $(shell date -u +%FT%TZ)

# Extract latest release semver from GitHub
SOROBAN_RPC_LATEST_RELEASE := $(shell curl -sS https://api.github.com/repos/stellar/soroban-tools/releases/latest|jq -r ".tag_name"| tr -d "v" )

# If deb version was provided via the SOROBAN_RPC_VERSION variable use it.
# If not get latest deb build matching release from GitHub
ifndef SOROBAN_RPC_VERSION
SOROBAN_RPC_VERSION_PACKAGE_VERSION := $(shell curl -sS https://apt.stellar.org/dists/focal/unstable/binary-amd64/Packages|grep -A 18 stellar-soroban-rpc|grep Version|grep $(SOROBAN_RPC_LATEST_RELEASE)|head -1|cut -d' ' -f2 )
else
SOROBAN_RPC_VERSION_PACKAGE_VERSION := $(SOROBAN_RPC_VERSION)
endif

ifndef SOROBAN_RPC_VERSION_PACKAGE_VERSION
$(error Couldn't establish deb build from version $(SOROBAN_RPC_LATEST_RELEASE). Has the package been built?)
endif

ifndef STELLAR_CORE_VERSION
$(error STELLAR_CORE_VERSION environment variable must be set. For example 19.10.1-1310.6649f5173.focal~soroban)
endif

TAG ?= stellar/stellar-soroban-rpc:$(SOROBAN_RPC_VERSION_PACKAGE_VERSION)

docker-build:
$(SUDO) docker build --pull --platform linux/amd64 $(DOCKER_OPTS) \
--label org.opencontainers.image.created="$(BUILD_DATE)" \
--build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) --build-arg SOROBAN_RPC_VERSION=$(SOROBAN_RPC_VERSION_PACKAGE_VERSION) \
-t $(TAG) -f Dockerfile.release .

docker-push:
$(SUDO) docker push $(TAG)

0 comments on commit 94af5fa

Please sign in to comment.