Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker file to build 2 images based on BINARY_NAME #300

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"]
14 changes: 14 additions & 0 deletions cmd/soroban-rpc/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,26 @@ ifndef STELLAR_CORE_VERSION
$(error STELLAR_CORE_VERSION environment variable must be set. For example 19.10.1-1310.6649f5173.focal~soroban)
endif

BINARY_NAME ?= soroban-rpc
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
Loading