-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
106 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Env file | ||
*.env | ||
|
||
docker-compose.override.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
all: up passwd | ||
default: help | ||
include *.mk | ||
|
||
.PHONY: pull | ||
pull: | ||
./remote.sh docker-compose pull | ||
|
||
.PHONY: up | ||
up: pull | ||
./remote.sh docker-compose up -d | ||
|
||
.PHONY: clean | ||
clean: | ||
./remote.sh docker-compose down | ||
./remote.sh docker-compose kill | ||
./remote.sh docker-compose rm | ||
start: docker-compose-start ##- Start | ||
deploy: docker-compose-deploy ##- Deploy (start remotely) | ||
|
||
.PHONY: passwd | ||
passwd: | ||
passwd: environment | ||
@echo "Changing password for user 'docker'" | ||
./remote.sh docker-compose run --entrypoint htpasswd registry -cB /auth/htpasswd docker | ||
$(load_env); docker-compose run --entrypoint htpasswd registry -cB /auth/htpasswd docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
compose_files := | ||
|
||
.PHONY: docker-compose-pull | ||
docker-compose-pull: environment ##- Pull latest containers | ||
$(info *** Pulling containers ***) | ||
-$(load_env); docker-compose ${compose_files} pull | ||
|
||
.PHONY: docker-compose-build | ||
docker-compose-build: environment ##- Build containers | ||
$(info *** Building containers ***) | ||
$(load_env); docker-compose ${compose_files} build | ||
|
||
.PHONY: docker-compose-start | ||
docker-compose-start: environment ##- Start containers | ||
$(info *** Starting containers ***) | ||
$(load_env); docker-compose ${compose_files} up -d | ||
|
||
.PHONY: docker-compose-stop | ||
docker-compose-stop: environment ##- Stop containers | ||
$(info *** Stopping containers ***) | ||
$(load_env); docker-compose ${compose_files} down | ||
|
||
.PHONY: docker-compose-logs | ||
docker-compose-logs: environment ##- Print containers logs | ||
$(info *** Printing containers logs ***) | ||
$(load_env); docker-compose ${compose_files} logs -f | ||
|
||
.PHONY: docker-compose-check-remote-env | ||
docker-compose-check-remote-env: environment ##- Check environment variables | ||
$(info *** Checking env variables ***) | ||
$(load_env); test $$DOCKER_HOST | ||
$(load_env); test $$COMPOSE_PROJECT_NAME | ||
|
||
.PHONY: docker-compose-deploy | ||
docker-compose-deploy: docker-compose-check-remote-env docker-compose-start ##- Deploy containers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
stage=${1:-'default'} | ||
|
||
cat <<EOF | ||
COMPOSE_PROJECT_NAME=registry | ||
EOF | ||
|
||
case "$stage" in | ||
"default") | ||
cat <<-EOF | ||
EOF | ||
;; | ||
|
||
"production") | ||
cat <<-EOF | ||
EOF | ||
;; | ||
|
||
*) | ||
echo "Unknown stage $stage" >&2 | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
stage ?= default | ||
|
||
.PHONY: environment | ||
environment: ${stage}.env ##- Define environment variables | ||
@test ${stage} || (echo 'stage not set'; exit 1) | ||
@$(eval ENV_FILE?=./${stage}.env) | ||
@$(eval load_env=set -a;. ${ENV_FILE};set +a) | ||
|
||
%.env: env.sh | ||
@echo "Env file $@ is not found or obsolete" | ||
@echo "Please update it (review and touch, or call make [-e stage=${stage}] generate-env)"; exit 1 | ||
|
||
.PHONY: generate-env | ||
generate-env: env.sh ##- Generate environment file ${stage}.env | ||
@test ${stage} || (echo 'stage not set'; exit 1) | ||
@./env.sh ${stage} > ${stage}.env | ||
@$(eval OVERRIDE_ENV_FILE?=./override.env) | ||
@[ -f "${OVERRIDE_ENV_FILE}" ] && echo "Appending environment override"; true | ||
@(([ -x "${OVERRIDE_ENV_FILE}" ] && "${OVERRIDE_ENV_FILE}") || \ | ||
([ -r "${OVERRIDE_ENV_FILE}" ] && cat "${OVERRIDE_ENV_FILE}") || true) | tee -a ${stage}.env | ||
@echo "Environment file ${stage}.env generated" | ||
|
||
.PHONY: dump-env | ||
dump-env: environment ##- Dump environment | ||
@echo "dump ENV_FILE: ${ENV_FILE}" | ||
$(load_env); env | ||
|
||
.PHONY: shell-env | ||
shell-env: environment ##- Start a local shell with environment | ||
@$(load_env); PS1='env$$ ' ${SHELL} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
help: ##- Show this help. | ||
@echo 'Usage: make <target> (see target list below)' | ||
@echo | ||
@sed -e '/#\{2\}-/!d; s/\\$$//; s/:[^#\t]*/:/; s/#\{2\}-*//' $(MAKEFILE_LIST) |