to.cler.be/Makefile

51 lines
1.5 KiB
Makefile

SOURCES=$(wildcard src/*.nim)
TARGET_ENV ?= local
ECR_ACCOUNT_URL ?= 063932952339.dkr.ecr.us-west-2.amazonaws.com
VERSION ?=`git describe`
PORT ?= 8080
TARGET_SERVER ?= sobeck.jdb-software.com
default: serve-docker
build: $(SOURCES)
nimble build
serve: build
TOCLERBE_PORT=$(PORT) \
TOCLERBE_API_KEYS=qwertyasdfgh \
./toclerbe urls.txt
# Build the container image.
build-image: $(SOURCES)
docker image build -t $(ECR_ACCOUNT_URL)/toclerbe:$(VERSION) .
# Push the container image to the private AWS ECR
push-image: build-image
docker push $(ECR_ACCOUNT_URL)/toclerbe:$(VERSION)
serve-docker: build-image
docker run \
-v "data:/data" \
-e TOCLERBE_PORT=80 \
-e TOCLERBE_API_KEYS=qwertyasdfgh \
-e "ISSUER=$(ISSUER)" \
-p 127.0.0.1:$(PORT):80/tcp \
$(ECR_ACCOUNT_URL)/toclerbe:$(VERSION)
ecr-auth:
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin $(ECR_ACCOUNT_URL)
publish:
-mkdir deploy
m4 -D "TOCLERBE_VERSION=$(VERSION)" \
toclerbe.service \
> deploy/toclerbe.service
-ssh deployer@$(TARGET_SERVER) "docker stop toclerbe.service && sudo systemctl stop toclerbe"
ssh deployer@$(TARGET_SERVER) "aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_ACCOUNT_URL) && docker pull $(ECR_ACCOUNT_URL)/toclerbe:$(VERSION)"
scp \
deploy/toclerbe.service \
deployer@$(TARGET_SERVER):/etc/systemd/system/toclerbe.service
ssh deployer@$(TARGET_SERVER) "sudo systemctl daemon-reload"
ssh deployer@$(TARGET_SERVER) "sudo systemctl start toclerbe"