Merge branch 'deal_with_unset_docker_login' into 'master'

Deal with unset docker login

See merge request pub/make-deploy!7
This commit is contained in:
Stefan Riepenhausen 2024-06-05 09:29:49 +02:00
commit c5ed8be31b
8 changed files with 91 additions and 5 deletions

2
apt.mk
View File

@ -1,4 +1,4 @@
MANDATORY-apt = APT_PACKAGES
MANDATORY-apt = DEPLOY_HOSTS SSH_USER APT_PACKAGES DEPLOY_NAME
pull-apt:
# nop

View File

@ -1,4 +1,8 @@
MANDATORY-compose-file = DEPLOY_HOSTS DEPLOY_TYPE TAG DEPLOY_COMPOSE_FILE DEPLOY_COMPOSE_PROJECT
MANDATORY-compose-file = DEPLOY_HOSTS DEPLOY_TYPE SSH_USER DEPLOY_COMPOSE_FILE DEPLOY_COMPOSE_PROJECT
ifndef DOCKER_LOGIN
DOCKER_LOGIN = 0
endif
pull-compose-file:
@- echo "\n### pulling image(s)"
@ -9,7 +13,10 @@ pull-compose-file:
echo "\n#### perfom docker login with user $(DOCKER_USER) on $(DOCKER_REGISTRY)"; \
ssh $(SSH_USER)@$(host) "docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY)"; \
fi; \
if test -n "$(DOCKER_IMAGE)" ; \
then \
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
fi; \
)
start-compose-file:

View File

@ -1,4 +1,8 @@
MANDATORY-compose = DEPLOY_HOSTS DEPLOY_TYPE TAG
MANDATORY-compose = DEPLOY_HOSTS DEPLOY_TYPE SSH_USER DEPLOY_NAME
ifndef DOCKER_LOGIN
DOCKER_LOGIN = 0
endif
pull-compose:
@- echo "\n### pulling image(s)"
@ -9,7 +13,10 @@ pull-compose:
echo "\n#### perfom docker login with user $(DOCKER_USER) on $(DOCKER_REGISTRY)"; \
ssh $(SSH_USER)@$(host) "docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY)"; \
fi; \
if test -n "$(DOCKER_IMAGE)" ; \
then \
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
fi; \
)
start-compose:

50
test.sh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
set -e
DIR=$(mktemp -d)
TESTS=$DIR/make-deploy/testing
function prepdir() {
mkdir $DIR/make-deploy
cp -r * $DIR/make-deploy
cd $DIR
ln -s make-deploy/Makefile
touch secrets.mk
echo "::::::::: testing directory root: $DIR"
}
function cleandir(){
rm -fr $DIR
echo "::::::::: cleanup done"
}
function test_with_minimal_vars_apt(){
echo "::::::::: $FUNCNAME ::::::::::::"
cp $TESTS/apt_config.mk config.mk
make deploy
}
function test_with_minimal_vars_compose(){
echo "::::::::: $FUNCNAME ::::::::::::"
cp $TESTS/compose_config.mk config.mk
cp $TESTS/docker-compose.yml .
make deploy
rm -f docker-compose.yml
}
function test_with_minimal_vars_compose_file(){
echo "::::::::: $FUNCNAME ::::::::::::"
cp $TESTS/compose_file_config.mk config.mk
cp $TESTS/docker-compose.yml .
make deploy
rm -f docker-compose.yml
}
prepdir
test_with_minimal_vars_apt
test_with_minimal_vars_compose
test_with_minimal_vars_compose_file
cleandir

6
testing/apt_config.mk Normal file
View File

@ -0,0 +1,6 @@
DEPLOY_NAME = make-deploy-test-apt
DEPLOY_PATH = /tmp
DEPLOY_HOSTS = localhost
DEPLOY_TYPE = apt
SSH_USER = $(USER)
APT_PACKAGES = curl

View File

@ -0,0 +1,5 @@
DEPLOY_NAME = make-deploy-test-compose
DEPLOY_PATH = /tmp
DEPLOY_HOSTS = localhost
DEPLOY_TYPE = compose
SSH_USER = $(USER)

View File

@ -0,0 +1,7 @@
DEPLOY_NAME = make-deploy-test-compose-file
DEPLOY_PATH = /tmp
DEPLOY_HOSTS = localhost
DEPLOY_TYPE = compose-file
SSH_USER = $(USER)
DEPLOY_COMPOSE_PROJECT = make-deploy-test-compose-file
DEPLOY_COMPOSE_FILE = docker-compose.yml

View File

@ -0,0 +1,4 @@
services:
curl:
image: "alpine/curl"
command: -s -o /dev/null https://www.test.de