@@ -8,26 +8,83 @@ SHELLCHECK=docker run --rm $(VOLUME_MOUNTS) -w /v koalaman/shellcheck:stable $(S
88
99ENVSUBST_VARS =LOAD_SCRIPT_COMMIT_SHA
1010
11+ # Define the channels we want to build for
12+ CHANNELS =test stable
13+
14+ FILES =build/test/install.sh build/stable/install.sh build/stable/rootless-install.sh
15+
1116.PHONY : build
12- build : build/install.sh
17+ build : $( FILES )
1318
14- build/install.sh : install.sh
19+ build/% / install.sh : install.sh
1520 mkdir -p $(@D )
16- LOAD_SCRIPT_COMMIT_SHA=' $(shell git rev-parse HEAD)' envsubst ' $(addprefix $$,$(ENVSUBST_VARS))' < $< > $@
21+ sed ' s/DEFAULT_CHANNEL_VALUE="stable"/DEFAULT_CHANNEL_VALUE="$*"/' $< | \
22+ LOAD_SCRIPT_COMMIT_SHA=' $(shell git rev-parse HEAD)' envsubst ' $(addprefix $$,$(ENVSUBST_VARS))' > $@
23+
24+ build/% /rootless-install.sh : rootless-install.sh
25+ mkdir -p $(@D )
26+ sed ' s/DEFAULT_CHANNEL_VALUE="stable"/DEFAULT_CHANNEL_VALUE="$*"/' $< | \
27+ LOAD_SCRIPT_COMMIT_SHA=' $(shell git rev-parse HEAD)' envsubst ' $(addprefix $$,$(ENVSUBST_VARS))' > $@
1728
1829.PHONY : shellcheck
19- shellcheck : build/install.sh
20- $(SHELLCHECK ) $<
30+ shellcheck : $( FILES )
31+ $(SHELLCHECK ) $^
2132
2233.PHONY : test
23- test : build/install.sh
24- docker run --rm -i \
25- $(VOLUME_MOUNTS ) \
26- -w /v \
27- -e VERSION \
28- -e CHANNEL \
29- $(TEST_IMAGE ) \
30- sh " $<"
34+ test : $(foreach channel,$(CHANNELS ) ,build/$(channel ) /install.sh)
35+ for file in $^; do \
36+ (set -x; docker run --rm -it \
37+ $(VOLUME_MOUNTS ) \
38+ --privileged \
39+ -e HOME=/tmp \
40+ -v /var/lib/docker \
41+ -w /v \
42+ -e VERSION \
43+ -e CHANNEL \
44+ $(TEST_IMAGE ) \
45+ sh $$ file) | tail -n 30; \
46+ done
47+
48+ AWS? =docker run \
49+ -v ./build:/build \
50+ -e AWS_ACCESS_KEY_ID \
51+ -e AWS_SECRET_ACCESS_KEY \
52+ -e AWS_SESSION_TOKEN \
53+ --rm -it amazon/aws-cli
54+
55+ .PHONY : deploy
56+ deploy : build/$(CHANNEL ) /install.sh build/$(CHANNEL ) /rootless-install.sh
57+ ifeq ($(S3_BUCKET ) ,)
58+ $(error S3_BUCKET is empty.)
59+ endif
60+ ifeq ($(CF_DISTRIBUTION_ID ) ,)
61+ $(error CF_DISTRIBUTION_ID is empty.)
62+ endif
63+ ifeq ($(CHANNEL ) ,)
64+ $(error CHANNEL is empty.)
65+ endif
66+ $(AWS) s3 cp --acl public-read --content-type 'text/plain' /build/$(CHANNEL)/install.sh s3://$(S3_BUCKET)/index
67+ ifeq ($(CHANNEL ) ,stable)
68+ $(AWS) s3 cp --acl public-read --content-type 'text/plain' /build/$(CHANNEL)/rootless-install.sh s3://$(S3_BUCKET)/rootless
69+ endif
70+
71+ $(AWS) cloudfront create-invalidation --distribution-id $(CF_DISTRIBUTION_ID) --paths '/*'
72+
73+ .PHONY : diff
74+ diff : TMP_DIR=/tmp
75+ diff : CHANNEL=stable
76+ diff : SUBDOMAIN=$(if $(filter test,$(CHANNEL ) ) ,test,$(if $(filter stable,$(CHANNEL ) ) ,get,$(error Invalid CHANNEL: $(CHANNEL ) ) ) )
77+ diff : build/$(CHANNEL ) /install.sh build/$(CHANNEL ) /rootless-install.sh
78+ curl -sfSL https://$(SUBDOMAIN ) .docker.com -o $(TMP_DIR ) /install.sh
79+
80+ echo "# Diff $(CHANNEL) install.sh"
81+ diff --color=always -u build/$(CHANNEL)/install.sh $(TMP_DIR)/install.sh || true
82+
83+ ifeq ($(CHANNEL ) ,stable)
84+ curl -sfSL https://$(SUBDOMAIN).docker.com/rootless -o $(TMP_DIR)/rootless-install.sh
85+ echo "# Diff $(CHANNEL) rootless-install.sh"
86+ diff --color=always -u build/$(CHANNEL)/rootless-install.sh $(TMP_DIR)/rootless-install.sh || true
87+ endif
3188
3289.PHONY : clean
3390clean :
0 commit comments