-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
74 lines (54 loc) · 2.43 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
PLATFORMS := ubuntu-2004 ubuntu-2204 ubuntu-2404 debian-10 debian-11 debian-12 centos-7 centos-8 rhel-9 opensuse-155 opensuse-156 fedora-39 fedora-40 fedora-41
SLS_BINARY ?= ./node_modules/serverless/bin/serverless.js
deps:
npm install
docker-build:
@cd builder && docker compose build --parallel
AWS_ACCOUNT_ID:=$(shell aws sts get-caller-identity --output text --query 'Account')
AWS_REGION := us-east-1
docker-push: ecr-login docker-build
@for platform in $(PLATFORMS) ; do \
docker tag r-builds:$$platform $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/r-builds:$$platform; \
docker push $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/r-builds:$$platform; \
done
docker-down:
@cd builder && docker compose down
docker-build-r: docker-build
@cd builder && docker compose up
docker-shell-r-env:
@cd builder && docker compose run --entrypoint /bin/bash ubuntu-2004
ecr-login:
(aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com)
push-serverless-custom-file:
aws s3 cp serverless-custom.yml s3://rstudio-devops/r-builds/serverless-custom.yml
fetch-serverless-custom-file:
aws s3 cp s3://rstudio-devops/r-builds/serverless-custom.yml .
rebuild-all: deps fetch-serverless-custom-file
$(SLS_BINARY) invoke stepf -n rBuilds -d '{"force": true}'
serverless-deploy.%: deps fetch-serverless-custom-file
$(SLS_BINARY) deploy --stage $* --verbose
define GEN_TARGETS
docker-build-$(platform):
@cd builder && docker compose build $(platform)
build-r-$(platform):
@cd builder && R_VERSION=$(R_VERSION) docker compose run --rm $(platform)
test-r-$(platform):
@cd test && R_VERSION=$(R_VERSION) docker compose run --rm $(platform)
bash-$(platform):
docker run -it --rm --entrypoint /bin/bash -v $(CURDIR):/r-builds r-builds:$(platform)
.PHONY: docker-build-$(platform) build-r-$(platform) test-r-$(platform) bash-$(platform)
endef
$(foreach platform,$(PLATFORMS), \
$(eval $(GEN_TARGETS)) \
)
print-platforms:
@echo $(PLATFORMS)
# Helper for launching a bash session on a docker image of your choice. Defaults
# to "ubuntu:xenial".
TARGET_IMAGE?=ubuntu:xenial
bash:
docker run --privileged=true -it --rm \
-v $(CURDIR):/r-builds \
-w /r-builds \
${TARGET_IMAGE} /bin/bash
.PHONY: deps docker-build docker-push docker-down docker-build-package docker-shell-package-env ecr-login fetch-serverless-custom-file print-platforms serverless-deploy