1
0
www.mikescher.com/Makefile

67 lines
2.5 KiB
Makefile
Raw Normal View History

2022-12-10 18:24:39 +01:00
DOCKER_REPO="registry.blackforestbytes.com"
DOCKER_NAME=mikescher/website-mscom
NAMESPACE=$(shell git rev-parse --abbrev-ref HEAD)
HASH=$(shell git rev-parse HEAD)
run:
php -S localhost:8000 -t .
2023-08-27 01:13:47 +02:00
dgi:
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
2023-09-12 17:43:01 +02:00
echo -n "VCSTYPE=" >> DOCKER_GIT_INFO ; { echo -n "git" ; echo ""; } >> DOCKER_GIT_INFO
echo -n "BRANCH=" >> DOCKER_GIT_INFO ; { git rev-parse --abbrev-ref HEAD ; } >> DOCKER_GIT_INFO
echo -n "HASH=" >> DOCKER_GIT_INFO ; { git rev-parse HEAD ; } >> DOCKER_GIT_INFO
echo -n "COMMITTIME=" >> DOCKER_GIT_INFO ; { git log -1 --format=%cd --date=iso ; } >> DOCKER_GIT_INFO
echo -n "REMOTE=" >> DOCKER_GIT_INFO ; { git remote -v | awk '{print $$2}' | uniq | tr '\n' ';'; echo ""; } >> DOCKER_GIT_INFO
echo -n "MESSAGE=" >> DOCKER_GIT_INFO ; { git log -1 --format=%B | awk '{s=s $$0 "\n"}END{sub(/\n+$$/,"",s);printf "%s",s}' | base64 --wrap=0; echo ""; } >> DOCKER_GIT_INFO
2023-08-27 01:13:47 +02:00
docker: dgi
2022-12-10 18:24:39 +01:00
docker build \
-t $(DOCKER_NAME):$(HASH) \
-t $(DOCKER_NAME):$(NAMESPACE)-latest \
-t $(DOCKER_NAME):latest \
-t $(DOCKER_REPO)/$(DOCKER_NAME):$(HASH) \
-t $(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest \
-t $(DOCKER_REPO)/$(DOCKER_NAME):latest \
.
run-docker: docker
2022-12-10 18:24:39 +01:00
mkdir -p ".run-data"
docker run --rm \
2023-08-27 01:13:47 +02:00
-it \
2022-12-10 18:24:39 +01:00
--init \
--publish 8080:80 \
--env "SMTP=0" \
--volume "$(shell pwd)/www/config.php:/var/www/html/config.php:ro" \
--volume "$(shell pwd)/.run-data/dynamic:/var/www/html/dynamic" \
2022-12-10 18:24:39 +01:00
$(DOCKER_NAME):latest
run-docker-live: docker
2022-12-10 18:24:39 +01:00
mkdir -p "$(shell pwd)/.run-data"
docker run --rm \
2023-08-27 01:13:47 +02:00
-it \
2022-12-10 18:24:39 +01:00
--init \
--publish 8080:80 \
--volume "$(shell pwd)/www:/var/www/html/" \
--env "SMTP=0" \
$(DOCKER_NAME):latest
inspect-docker:
docker run -ti \
--rm \
$(DOCKER_NAME):latest \
bash
push-docker:
2022-12-10 18:24:39 +01:00
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):$(HASH)
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):latest
clean:
rm -rf ".run-data"
git clean -fdx