Skip to content

Commit fb6d425

Browse files
Move Core Dockerfile into repo and reduce size (#769)
1 parent 9ba80cc commit fb6d425

File tree

5 files changed

+53
-12
lines changed

5 files changed

+53
-12
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ env:
6868
# Cache ID is a value inserted into cache keys. Whenever changing the build
6969
# in a way that needs to use entirely new fresh builds, increment the number
7070
# by one so that all the keys become new.
71-
CACHE_ID: 3
71+
CACHE_ID: 4
7272
ARTIFACT_RETENTION_DAYS_FOR_IMAGE: 7
7373
ARTIFACT_RETENTION_DAYS_FOR_LOGS: 60
7474

@@ -89,7 +89,7 @@ jobs:
8989
- id: xdr
9090
run: echo "sha=$(gh api repos/stellar/rs-stellar-xdr/commits/"${{inputs.xdr_ref}}" --jq '.sha')" | tee -a $GITHUB_OUTPUT
9191
- id: core
92-
run: echo "sha=$(gh api repos/"${{inputs.core_repo}}"/commits/"${{inputs.core_ref}}" --jq '.sha')" | tee -a $GITHUB_OUTPUT
92+
run: echo "sha=$(gh api repos/${{inputs.core_repo}}/commits/"${{inputs.core_ref}}" --jq '.sha')" | tee -a $GITHUB_OUTPUT
9393
- id: rpc
9494
run: echo "sha=$(gh api repos/stellar/stellar-rpc/commits/"${{inputs.stellar_rpc_ref}}" --jq '.sha')" | tee -a $GITHUB_OUTPUT
9595
- id: horizon
@@ -123,6 +123,10 @@ jobs:
123123
if: ${{ needs.load-stellar-core-from-cache.outputs.cache-hit != 'true' }}
124124
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
125125
steps:
126+
- name: Checkout Quickstart for Core docker file
127+
uses: actions/checkout@v3
128+
with:
129+
ref: ${{ inputs.sha }}
126130
- id: cache
127131
uses: actions/cache@v3
128132
with:
@@ -136,11 +140,12 @@ jobs:
136140
- name: Build Stellar-Core Image
137141
run: >
138142
docker buildx build --platform linux/${{ inputs.arch }}
139-
-f docker/Dockerfile.testing -t stellar-core:${{ inputs.arch }}
143+
-f Dockerfile.core
144+
-t stellar-core:${{ inputs.arch }}
140145
-o type=docker,dest=/tmp/image
141-
https://github.com/${{ inputs.core_repo }}.git#${{ needs.shas.outputs.core }}
142-
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
143-
--build-arg CONFIGURE_FLAGS='${{ inputs.core_configure_flags }}'
146+
--build-arg REPO="${{ inputs.core_repo }}"
147+
--build-arg REF="${{ needs.shas.outputs.core }}"
148+
--build-arg CONFIGURE_FLAGS='${{ inputs.core_configure_flags }}' .
144149
- name: Upload Stellar-Core Image
145150
uses: actions/upload-artifact@v4
146151
with:
@@ -401,7 +406,7 @@ jobs:
401406
-f Dockerfile.xdr
402407
-t stellar-rs-xdr:${{ inputs.arch }}
403408
-o type=docker,dest=/tmp/image
404-
--build-arg REPO=https://github.com/stellar/rs-stellar-xdr.git
409+
--build-arg REPO=stellar/rs-stellar-xdr
405410
--build-arg REF="${{ needs.shas.outputs.xdr }}" .
406411
- name: Upload Stellar-Rs-Xdr Image
407412
uses: actions/upload-artifact@v4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ADD dependencies /
3030
RUN /dependencies
3131

3232
COPY --from=stellar-xdr /stellar-xdr /usr/local/bin/stellar-xdr
33-
COPY --from=stellar-core /usr/local/bin/stellar-core /usr/bin/stellar-core
33+
COPY --from=stellar-core /stellar-core /usr/bin/stellar-core
3434
COPY --from=horizon /horizon /usr/bin/stellar-horizon
3535
COPY --from=friendbot /friendbot /usr/local/bin/friendbot
3636
COPY --from=stellar-rpc /stellar-rpc /usr/bin/stellar-rpc

Dockerfile.core

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:focal AS builder
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update && \
5+
apt-get -y install iproute2 procps lsb-release \
6+
git build-essential pkg-config autoconf automake libtool \
7+
bison flex sed perl libpq-dev parallel libunwind-dev \
8+
clang-12 libc++abi-12-dev libc++-12-dev \
9+
postgresql curl
10+
11+
ARG REPO
12+
ARG REF
13+
WORKDIR /wd
14+
RUN git clone https://github.com/${REPO} /wd
15+
RUN git fetch origin ${REF}
16+
RUN git checkout ${REF}
17+
18+
RUN git clean -dXf
19+
RUN git submodule foreach --recursive git clean -dXf
20+
21+
ARG CC=clang-12
22+
ARG CXX=clang++-12
23+
ARG CFLAGS='-O3 -g1'
24+
ARG CXXFLAGS='-O3 -g1'
25+
ARG CONFIGURE_FLAGS=''
26+
27+
RUN ./autogen.sh
28+
RUN ./install-rust.sh
29+
ENV PATH "/root/.cargo/bin:$PATH"
30+
RUN ./configure CC="${CC}" CXX="${CXX}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ${CONFIGURE_FLAGS}
31+
RUN sh -c 'make -j $(nproc)'
32+
RUN make install
33+
34+
FROM scratch AS artifacts
35+
36+
COPY --from=builder /usr/local/bin/stellar-core /stellar-core

Dockerfile.xdr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM rust AS builder
33
ARG REPO
44
ARG REF
55
WORKDIR /wd
6-
RUN git clone ${REPO} /wd
6+
RUN git clone https://github.com/${REPO} /wd
77
RUN git fetch origin ${REF}
88
RUN git checkout ${REF}
99
RUN rustup show active-toolchain || rustup toolchain install

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ __PHONY__: run logs build build-deps build-deps-core build-deps-horizon build-de
33
REVISION=$(shell git -c core.abbrev=no describe --always --exclude='*' --long --dirty)
44
TAG?=dev
55
PROTOCOL_VERSION_DEFAULT?=22
6-
XDR_REPO?=https://github.com/stellar/rs-stellar-xdr.git
6+
XDR_REPO?=stellar/rs-stellar-xdr
77
XDR_REF?=main
8-
CORE_REPO?=https://github.com/stellar/stellar-core.git
8+
CORE_REPO?=stellar/stellar-core
99
CORE_REF?=master
1010
CORE_CONFIGURE_FLAGS?=--disable-tests
1111
STELLAR_RPC_REF?=main
@@ -67,7 +67,7 @@ build-deps-xdr:
6767
docker build -t stellar-xdr:$(XDR_REF) -f Dockerfile.xdr . --build-arg REPO="$(XDR_REPO)" --build-arg REF="$(XDR_REF)"
6868

6969
build-deps-core:
70-
docker build -t stellar-core:$(CORE_REF) -f docker/Dockerfile.testing $(CORE_REPO)#$(CORE_REF) --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true --build-arg CONFIGURE_FLAGS="$(CORE_CONFIGURE_FLAGS)"
70+
docker build -t stellar-core:$(CORE_REF) -f Dockerfile.core . --build-arg REPO="$(CORE_REPO)" --build-arg REF="$(CORE_REF)" --build-arg CONFIGURE_FLAGS="$(CORE_CONFIGURE_FLAGS)"
7171

7272
build-deps-horizon:
7373
docker build -t stellar-horizon:$(HORIZON_REF) -f Dockerfile.horizon . --build-arg REF="$(HORIZON_REF)"

0 commit comments

Comments
 (0)