-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (42 loc) · 2.52 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
check:
golangci-lint run -v
check-fix:
golangci-lint run --fix
docker-build: build-url-shortener build-postgres build-backup
build-url-shortener:
DOCKER_BUILDKIT=1 docker --log-level=debug build --pull --build-arg BUILDKIT_INLINE_CACHE=1 \
--target builder \
--cache-from ${REGISTRY}/url-shortener:cache-builder \
--tag ${REGISTRY}/url-shortener:cache-builder \
--file ./Dockerfile .
DOCKER_BUILDKIT=1 docker --log-level=debug build --pull --build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from ${REGISTRY}/url-shortener:cache-builder \
--cache-from ${REGISTRY}/url-shortener:cache \
--tag ${REGISTRY}/url-shortener:cache \
--tag ${REGISTRY}/url-shortener:${IMAGE_TAG} \
--file ./Dockerfile .
build-postgres:
DOCKER_BUILDKIT=1 docker --log-level=debug build --pull --build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from ${REGISTRY}/url-shortener-postgres:cache \
--tag ${REGISTRY}/url-shortener-postgres:cache \
--tag ${REGISTRY}/url-shortener-postgres:${IMAGE_TAG} \
--file docker/postgres/Dockerfile docker/postgres
build-backup:
docker --log-level=debug build --pull --file=docker/common/postgres-backup/Dockerfile --tag=${REGISTRY}/url-shortener-postgres-backup:${IMAGE_TAG} docker/common
push-build-cache:
docker push ${REGISTRY}/url-shortener:cache-builder
docker push ${REGISTRY}/url-shortener:cache
docker push ${REGISTRY}/url-shortener-postgres:cache
push:
docker push ${REGISTRY}/url-shortener:${IMAGE_TAG}
docker push ${REGISTRY}/url-shortener-postgres:${IMAGE_TAG}
docker push ${REGISTRY}/url-shortener-postgres-backup:${IMAGE_TAG}
deploy:
ssh -o StrictHostKeyChecking=no deploy@${HOST} -p ${PORT} 'docker network create --driver=overlay traefik-public || true'
ssh -o StrictHostKeyChecking=no deploy@${HOST} -p ${PORT} 'rm -rf url_shortener_${BUILD_NUMBER} && mkdir url_shortener_${BUILD_NUMBER}'
envsubst < docker-compose-production.yml > docker-compose-production-env.yml
scp -o StrictHostKeyChecking=no -P ${PORT} docker-compose-production-env.yml deploy@${HOST}:url_shortener_${BUILD_NUMBER}/docker-compose.yml
rm -f docker-compose-production-env.yml
ssh -o StrictHostKeyChecking=no deploy@${HOST} -p ${PORT} 'mkdir url_shortener_${BUILD_NUMBER}/secrets'
ssh -o StrictHostKeyChecking=no deploy@${HOST} -p ${PORT} 'cp .secrets_url_shortener/* url_shortener_${BUILD_NUMBER}/secrets'
ssh -o StrictHostKeyChecking=no deploy@${HOST} -p ${PORT} 'cd url_shortener_${BUILD_NUMBER} && docker stack deploy --compose-file docker-compose.yml url-shortener --with-registry-auth --prune'