Skip to content

Commit 7d93b60

Browse files
update makefile to use images-with-extras script and sha references
1 parent 3313555 commit 7d93b60

4 files changed

Lines changed: 42 additions & 38 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ jobs:
245245
echo "$(<<< $image_json jq -r '.deps[] | "\(.name)=\(.id)"')" | tee -a $GITHUB_OUTPUT
246246
- name: Write Image Config
247247
run: |
248-
echo "$image_json" > image.json
248+
echo "$image_json" > .image.json
249249
- name: Download Image XDR
250250
uses: actions/download-artifact@v4
251251
with:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/image.json
1+
/.image.json

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ RUN adduser --system --group --quiet --home /var/lib/stellar --disabled-password
4242
RUN ["mkdir", "-p", "/opt/stellar"]
4343
RUN ["touch", "/opt/stellar/.docker-ephemeral"]
4444

45-
ADD image.json /image.json
45+
ADD .image.json /image.json
4646

4747
RUN ["rm", "-fr", "/etc/supervisor"]
4848
RUN ["ln", "-sT", "/opt/stellar/supervisor/etc", "/etc/supervisor"]

Makefile

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ __PHONY__: run logs console build build-deps build-deps-xdr build-deps-core buil
33
REVISION=$(shell git -c core.abbrev=no describe --always --exclude='*' --long --dirty)
44
TAG?=latest
55

6-
# Extract configuration from images.json
7-
PROTOCOL_VERSION_DEFAULT = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .config.protocol_version_default' images.json)
8-
XDR_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "xdr") | .repo' images.json)
9-
XDR_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "xdr") | .ref' images.json)
10-
CORE_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "core") | .repo' images.json)
11-
CORE_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "core") | .ref' images.json)
12-
CORE_OPTIONS = $(shell jq -c '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "core") | .options // {}' images.json)
13-
RPC_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "rpc") | .repo' images.json)
14-
RPC_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "rpc") | .ref' images.json)
15-
HORIZON_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "horizon") | .repo' images.json)
16-
HORIZON_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "horizon") | .ref' images.json)
17-
FRIENDBOT_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "friendbot") | .repo' images.json)
18-
FRIENDBOT_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "friendbot") | .ref' images.json)
19-
LAB_REPO = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "lab") | .repo' images.json)
20-
LAB_REF = $(shell jq -r '.[] | select(.tag == "$(TAG)") | .deps[] | select(.name == "lab") | .ref' images.json)
6+
# Process images.json through the images-with-extras script
7+
IMAGE_JSON=.image.json
8+
.image.json: images.json .scripts/images-with-extras
9+
< images.json .scripts/images-with-extras | jq '.[] | select(.tag == "$(TAG)")' > $@
10+
11+
# Extract configuration from selected image
12+
PROTOCOL_VERSION_DEFAULT = $(shell < $(IMAGE_JSON) jq -r '.config.protocol_version_default')
13+
XDR_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "xdr") | .repo')
14+
XDR_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "xdr") | .sha')
15+
CORE_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "core") | .repo')
16+
CORE_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "core") | .sha')
17+
CORE_OPTIONS = $(shell < $(IMAGE_JSON) jq -c '.deps[] | select(.name == "core") | .options // {}')
18+
RPC_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "rpc") | .repo')
19+
RPC_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "rpc") | .sha')
20+
HORIZON_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "horizon") | .repo')
21+
HORIZON_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "horizon") | .sha')
22+
FRIENDBOT_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "friendbot") | .repo')
23+
FRIENDBOT_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "friendbot") | .sha')
24+
LAB_REPO = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "lab") | .repo')
25+
LAB_SHA = $(shell < $(IMAGE_JSON) jq -r '.deps[] | select(.name == "lab") | .sha')
2126

2227
run:
2328
docker run --rm --name stellar -p 8000:8000 stellar/quickstart:$(TAG) --local
@@ -28,35 +33,34 @@ logs:
2833
console:
2934
docker exec -it stellar /bin/bash
3035

31-
build:
32-
< images.json jq -c --arg tag '$(TAG)' '.[] | select(.tag == $$tag)' > image.json
36+
build: $(IMAGE_JSON)
3337
$(MAKE) build-deps
3438
docker build -t stellar/quickstart:$(TAG) -f Dockerfile . \
3539
--build-arg REVISION=$(REVISION) \
3640
--build-arg PROTOCOL_VERSION_DEFAULT=$(PROTOCOL_VERSION_DEFAULT) \
37-
--build-arg XDR_IMAGE_REF=stellar-xdr:$(XDR_REF) \
38-
--build-arg CORE_IMAGE_REF=stellar-core:$(CORE_REF) \
39-
--build-arg RPC_IMAGE_REF=stellar-rpc:$(RPC_REF) \
40-
--build-arg HORIZON_IMAGE_REF=stellar-horizon:$(HORIZON_REF) \
41-
--build-arg FRIENDBOT_IMAGE_REF=stellar-friendbot:$(FRIENDBOT_REF) \
42-
--build-arg LAB_IMAGE_REF=stellar-lab:$(LAB_REF)
41+
--build-arg XDR_IMAGE_REF=stellar-xdr:$(XDR_SHA) \
42+
--build-arg CORE_IMAGE_REF=stellar-core:$(CORE_SHA) \
43+
--build-arg RPC_IMAGE_REF=stellar-rpc:$(RPC_SHA) \
44+
--build-arg HORIZON_IMAGE_REF=stellar-horizon:$(HORIZON_SHA) \
45+
--build-arg FRIENDBOT_IMAGE_REF=stellar-friendbot:$(FRIENDBOT_SHA) \
46+
--build-arg LAB_IMAGE_REF=stellar-lab:$(LAB_SHA)
4347

4448
build-deps: build-deps-xdr build-deps-rpc build-deps-horizon build-deps-friendbot build-deps-lab build-deps-core
4549

46-
build-deps-xdr:
47-
docker build -t stellar-xdr:$(XDR_REF) -f Dockerfile.xdr . --build-arg REPO="$(XDR_REPO)" --build-arg REF="$(XDR_REF)"
50+
build-deps-xdr: $(IMAGE_JSON)
51+
docker build -t stellar-xdr:$(XDR_SHA) -f Dockerfile.xdr . --build-arg REPO="$(XDR_REPO)" --build-arg REF="$(XDR_SHA)"
4852

49-
build-deps-core:
50-
docker build -t stellar-core:$(CORE_REF) -f Dockerfile.core . --build-arg REPO="$(CORE_REPO)" --build-arg REF="$(CORE_REF)" --build-arg OPTIONS='$(CORE_OPTIONS)'
53+
build-deps-core: $(IMAGE_JSON)
54+
docker build -t stellar-core:$(CORE_SHA) -f Dockerfile.core . --build-arg REPO="$(CORE_REPO)" --build-arg REF="$(CORE_SHA)" --build-arg OPTIONS='$(CORE_OPTIONS)'
5155

52-
build-deps-rpc:
53-
docker build -t stellar-rpc:$(RPC_REF) -f Dockerfile.rpc . --build-arg=REPO="$(RPC_REPO)" --build-arg REF="$(RPC_REF)"
56+
build-deps-rpc: $(IMAGE_JSON)
57+
docker build -t stellar-rpc:$(RPC_SHA) -f Dockerfile.rpc . --build-arg=REPO="$(RPC_REPO)" --build-arg REF="$(RPC_SHA)"
5458

55-
build-deps-horizon:
56-
docker build -t stellar-horizon:$(HORIZON_REF) -f Dockerfile.horizon . --build-arg REPO="$(HORIZON_REPO)" --build-arg REF="$(HORIZON_REF)"
59+
build-deps-horizon: $(IMAGE_JSON)
60+
docker build -t stellar-horizon:$(HORIZON_SHA) -f Dockerfile.horizon . --build-arg REPO="$(HORIZON_REPO)" --build-arg REF="$(HORIZON_SHA)"
5761

58-
build-deps-friendbot:
59-
docker build -t stellar-friendbot:$(FRIENDBOT_REF) -f Dockerfile.friendbot . --build-arg REPO="$(FRIENDBOT_REPO)" --build-arg REF="$(FRIENDBOT_REF)"
62+
build-deps-friendbot: $(IMAGE_JSON)
63+
docker build -t stellar-friendbot:$(FRIENDBOT_SHA) -f Dockerfile.friendbot . --build-arg REPO="$(FRIENDBOT_REPO)" --build-arg REF="$(FRIENDBOT_SHA)"
6064

61-
build-deps-lab:
62-
docker build -t stellar-lab:$(LAB_REF) -f Dockerfile.lab . --build-arg REPO="$(LAB_REPO)" --build-arg NEXT_PUBLIC_COMMIT_HASH=$(LAB_REF)
65+
build-deps-lab: $(IMAGE_JSON)
66+
docker build -t stellar-lab:$(LAB_SHA) -f Dockerfile.lab . --build-arg REPO="$(LAB_REPO)" --build-arg NEXT_PUBLIC_COMMIT_HASH=$(LAB_SHA)

0 commit comments

Comments
 (0)