Skip to content

Commit

Permalink
Update docker file to build 2 images based on BINARY_NAME (#300)
Browse files Browse the repository at this point in the history
* Update docker file to build 2 images based on argument

* Update docker-build and makefile

* remove duplicate assignments
  • Loading branch information
psheth9 authored Sep 25, 2024
1 parent e7debbe commit 953a504
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 11 additions & 4 deletions cmd/soroban-rpc/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.22-bullseye as build
ARG RUST_TOOLCHAIN_VERSION=stable
ARG REPOSITORY_VERSION
ARG BINARY_NAME=soroban-rpc

WORKDIR /go/src/github.com/stellar/soroban-rpc

Expand All @@ -18,11 +19,14 @@ RUN apt-get clean

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_TOOLCHAIN_VERSION

RUN make REPOSITORY_VERSION=${REPOSITORY_VERSION} build-soroban-rpc
RUN mv soroban-rpc /bin/soroban-rpc
RUN make REPOSITORY_VERSION=${REPOSITORY_VERSION} build-${BINARY_NAME}

# Move the binary to a common location
RUN mv ${BINARY_NAME} /bin/${BINARY_NAME}

FROM ubuntu:22.04
ARG STELLAR_CORE_VERSION
ARG BINARY_NAME=soroban-rpc
ENV STELLAR_CORE_VERSION=${STELLAR_CORE_VERSION:-*}
ENV STELLAR_CORE_BINARY_PATH /usr/bin/stellar-core
ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -35,5 +39,8 @@ RUN echo "deb https://apt.stellar.org focal unstable" >/etc/apt/sources.list.d/S
RUN apt-get update && apt-get install -y stellar-core=${STELLAR_CORE_VERSION}
RUN apt-get clean

COPY --from=build /bin/soroban-rpc /app/
ENTRYPOINT ["/app/soroban-rpc"]
# Copy the binary from the build stage
COPY --from=build /bin/${BINARY_NAME} /app/${BINARY_NAME}

# Set the entrypoint to the specific binary
ENTRYPOINT ["/app/${BINARY_NAME}"]
12 changes: 11 additions & 1 deletion cmd/soroban-rpc/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ 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)
# Set default value for BINARY_NAME if not provided
BINARY_NAME ?= soroban-rpc

# Set the TAG based on the value of BINARY_NAME
ifeq ($(BINARY_NAME),stellar-rpc)
TAG := stellar/stellar-rpc:$(SOROBAN_RPC_VERSION_PACKAGE_VERSION)
else
TAG := stellar/stellar-soroban-rpc:$(SOROBAN_RPC_VERSION_PACKAGE_VERSION)
endif


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) \
--build-arg BINARY_NAME=$(BINARY_NAME) \
-t $(TAG) -f Dockerfile.release .

docker-push:
Expand Down

0 comments on commit 953a504

Please sign in to comment.