Skip to content

Commit c6d849e

Browse files
committed
deploy: Add /repo endpoint for repository-only setup
Add a new /repo endpoint (get.docker.com/repo) that configures Docker's package repositories without installing Docker packages. This is the same install.sh just with REPO_ONLY defaulting to 1, equivalent to running install.sh --setup-repo. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent 8fb5881 commit c6d849e

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ENVSUBST_VARS=LOAD_SCRIPT_COMMIT_SHA LOAD_SCRIPT_STABLE_LATEST LOAD_SCRIPT_TEST_
1111
# Define the channels we want to build for
1212
CHANNELS=test stable
1313

14-
FILES=build/test/install.sh build/stable/install.sh build/stable/rootless-install.sh
14+
FILES=build/test/install.sh build/stable/install.sh build/stable/rootless-install.sh build/stable/setup-repo.sh
1515

1616
STABLE_LATEST=$(shell ./scripts/get-version.sh stable)
1717
TEST_LATEST=$(shell ./scripts/get-version.sh test)
@@ -45,6 +45,16 @@ build/%/rootless-install.sh: rootless-install.sh
4545
envsubst '$(addprefix $$,$(ENVSUBST_VARS))' > $@
4646
chmod +x $@
4747

48+
build/%/setup-repo.sh: install.sh
49+
mkdir -p $(@D)
50+
sed -e 's/DEFAULT_CHANNEL_VALUE="stable"/DEFAULT_CHANNEL_VALUE="$*"/' \
51+
-e 's/REPO_ONLY=$${REPO_ONLY:-0}/REPO_ONLY=$${REPO_ONLY:-1}/' $< | \
52+
LOAD_SCRIPT_COMMIT_SHA='$(shell git rev-parse HEAD)' \
53+
LOAD_SCRIPT_STABLE_LATEST='$(STABLE_LATEST)' \
54+
LOAD_SCRIPT_TEST_LATEST='$(TEST_LATEST)' \
55+
envsubst '$(addprefix $$,$(ENVSUBST_VARS))' > $@
56+
chmod +x $@
57+
4858
.PHONY: shellcheck
4959
shellcheck: $(FILES)
5060
$(SHELLCHECK) $^
@@ -72,7 +82,7 @@ AWS?=docker run \
7282
--rm amazon/aws-cli
7383

7484
.PHONY: deploy
75-
deploy: build/$(CHANNEL)/install.sh build/$(CHANNEL)/rootless-install.sh
85+
deploy: build/$(CHANNEL)/install.sh build/$(CHANNEL)/rootless-install.sh build/$(CHANNEL)/setup-repo.sh
7686
ifeq ($(S3_BUCKET),)
7787
$(error S3_BUCKET is empty.)
7888
endif
@@ -85,12 +95,13 @@ endif
8595
$(AWS) s3 cp --acl public-read --content-type 'text/plain' /build/$(CHANNEL)/install.sh s3://$(S3_BUCKET)/index
8696
ifeq ($(CHANNEL),stable)
8797
$(AWS) s3 cp --acl public-read --content-type 'text/plain' /build/$(CHANNEL)/rootless-install.sh s3://$(S3_BUCKET)/rootless
98+
$(AWS) s3 cp --acl public-read --content-type 'text/plain' /build/$(CHANNEL)/setup-repo.sh s3://$(S3_BUCKET)/repo
8899
endif
89100

90101
$(AWS) cloudfront create-invalidation --distribution-id $(CF_DISTRIBUTION_ID) --paths '/*'
91102

92103
.PHONY: diff
93-
diff: build/$(CHANNEL)/install.sh build/$(CHANNEL)/rootless-install.sh
104+
diff: build/$(CHANNEL)/install.sh build/$(CHANNEL)/rootless-install.sh build/$(CHANNEL)/setup-repo.sh
94105
ifeq ($(CHANNEL),)
95106
$(error CHANNEL is empty.)
96107
endif

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ From the source repo (This will install latest from the `stable` channel):
2929
sh install.sh
3030
```
3131

32+
### Repository Setup Only
33+
34+
To configure Docker's package repositories without installing Docker packages,
35+
use the `/repo` endpoint:
36+
37+
```shell
38+
curl -fsSL https://get.docker.com/repo | sh -
39+
```
40+
41+
This is equivalent to running `sh install.sh --setup-repo`.
42+
3243
## Testing:
3344

3445
To verify that the install script works amongst the supported operating systems run:

diff.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ if [[ "$CHANNEL" == "stable" ]] && [[ ! -f "build/$CHANNEL/rootless-install.sh"
3535
exit 1
3636
fi
3737

38+
if [[ "$CHANNEL" == "stable" ]] && [[ ! -f "build/$CHANNEL/setup-repo.sh" ]]; then
39+
echo "Error: build/$CHANNEL/setup-repo.sh not found" >&2
40+
exit 1
41+
fi
42+
3843
TMP_DIR=$(mktemp -d)
3944

4045
# Download and compare install.sh
@@ -45,13 +50,19 @@ if ! diff -u "$TMP_DIR/install.sh" "build/$CHANNEL/install.sh"; then
4550
DIFF_FOUND=1
4651
fi
4752

48-
# For stable channel, also compare rootless-install.sh
53+
# For stable channel, also compare rootless-install.sh and setup-repo.sh
4954
if [[ "$CHANNEL" == "stable" ]]; then
5055
curl -sfSL "https://$SUBDOMAIN.docker.com/rootless" -o "$TMP_DIR/rootless-install.sh"
5156
echo "# Diff $CHANNEL rootless-install.sh"
5257
if ! diff -u "$TMP_DIR/rootless-install.sh" "build/$CHANNEL/rootless-install.sh"; then
5358
DIFF_FOUND=1
5459
fi
60+
61+
curl -sfSL "https://$SUBDOMAIN.docker.com/repo" -o "$TMP_DIR/setup-repo.sh"
62+
echo "# Diff $CHANNEL setup-repo.sh"
63+
if ! diff -u "$TMP_DIR/setup-repo.sh" "build/$CHANNEL/setup-repo.sh"; then
64+
DIFF_FOUND=1
65+
fi
5566
fi
5667

5768
exit $DIFF_FOUND

0 commit comments

Comments
 (0)