-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (38 loc) · 2.25 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
srcs = $(shell find . -name '*.rs' -or -name 'Cargo.toml' -or -name 'Cargo.lock' -or -name 'Dockerfile' -or -name 'Makefile' -or -name '*.proto')
.DEFAULT_GOAL := run
.PHONY: docker docker-push docker-run windows-remote
windows-remote: target/x86_64-pc-windows-gnu/release/forwarder.exe
target/x86_64-pc-windows-gnu/release/forwarder.exe: $(srcs)
cross build --release --target x86_64-pc-windows-gnu --bin forwarder
docker-push: docker
docker push 413471642455.dkr.ecr.us-east-1.amazonaws.com/spotify-remote-receiver:latest
docker: $(srcs) Dockerfile
DOCKER_BUILDKIT=1 docker build . -t 413471642455.dkr.ecr.us-east-1.amazonaws.com/spotify-remote-receiver:latest
docker-run: docker
docker run -it --rm -e RUST_BACKTRACE=full -e RUST_LOG=spotify-remote-receiver=trace,info --env-file receiver/.env 413471642455.dkr.ecr.us-east-1.amazonaws.com/spotify-remote-receiver:latest
deploy: docker-push
$(MAKE) refresh-ecr
$(MAKE) restart
docker-creds-refresh:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 413471642455.dkr.ecr.us-east-1.amazonaws.com
deploy-multiarch: docker-multiarch
$(MAKE) refresh-ecr
$(MAKE) restart
$(MAKE) docker-arm-builder-down
docker-multiarch: Dockerfile $(srcs) docker-arm-ensure-builder-up docker-creds-refresh
docker buildx build --builder multiarch --platform linux/arm64,linux/amd64 --push \
-t 413471642455.dkr.ecr.us-east-1.amazonaws.com/spotify-remote-receiver:latest --ssh default \
--cache-to=type=local,dest=/tmp/.buildx-cache/spotify-remote \
--cache-from=type=local,src=/tmp/.buildx-cache/spotify-remote \
.
docker-arm-ensure-builder-up:
aws ec2 describe-instances --instance-ids i-00ab99709da8e22aa | jq -r '.Reservations[].Instances[].State.Name == "stopped"' | grep false || $(MAKE) docker-arm-builder-up
docker-arm-builder-up:
aws ec2 start-instances --instance-ids i-00ab99709da8e22aa
aws ec2 wait instance-running --instance-ids i-00ab99709da8e22aa
docker-arm-builder-down:
aws ec2 stop-instances --instance-ids i-00ab99709da8e22aa
# setup only
docker-create-builder:
docker buildx create --bootstrap --name multiarch --node local --platform linux/amd64
docker buildx create --bootstrap --name multiarch --append --node aws-ec2-arm --platform linux/arm64 ssh://docker-builder-1