Squash runners

This commit is contained in:
Wojciech Kozlowski 2018-12-18 00:39:51 +00:00
parent 9015cfbbe4
commit e52a6cd3ad
4 changed files with 81 additions and 150 deletions

View File

@ -1,11 +1,32 @@
after_script:
- make clean-all
image: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
docker:dind
build:
.builds:
only:
- schedules
tags:
- docker
script:
before_script:
- docker login -u $USERNAME -p $PASSWORD registry.wojciechkozlowski.eu
- make all
after_script:
- docker logout registry.wojciechkozlowski.eu
- make clean-all
proxy:
extends: .builds
script:
- make proxy
wiki:
extends: .builds
script:
- make wiki
nextcloud:
extends: .builds
script:
- make nextcloud

159
Makefile
View File

@ -24,21 +24,43 @@ DOCKER_REGISTRY = registry.wojciechkozlowski.eu/wojtek/loki
default: all
# -----------------------------------------------------------------------------
# proxy
# -----------------------------------------------------------------------------
PROXY = $(DOCKER_REGISTRY)/proxy
proxy-clean:
docker rmi $(PROXY) || /bin/true
proxy-build:
docker build -f proxy/Dockerfile -t $(PROXY) ./proxy
proxy-push:
docker push $(PROXY)
proxy-pull:
docker pull $(PROXY)
proxy: proxy-clean proxy-build proxy-push
# -----------------------------------------------------------------------------
# wiki
# -----------------------------------------------------------------------------
WIKI = $(DOCKER_REGISTRY)/wiki
wiki-clean:
docker rmi $(DOCKER_REGISTRY)/wiki || /bin/true
docker rmi $(WIKI) || /bin/true
wiki-build:
docker-compose build wiki
docker build -f dokuwiki/Dockerfile -t $(WIKI) ./dokuwiki
wiki-push:
docker-compose push wiki
docker push $(WIKI)
wiki-pull:
docker-compose pull wiki
docker pull $(WIKI)
wiki: wiki-clean wiki-build wiki-push
@ -46,114 +68,22 @@ wiki: wiki-clean wiki-build wiki-push
# nextcloud
# -----------------------------------------------------------------------------
NEXTCLOUD = $(DOCKER_REGISTRY)/nextcloud
nextcloud-clean:
docker rmi $(DOCKER_REGISTRY)/nextcloud || /bin/true
docker rmi $(NEXTCLOUD) || /bin/true
nextcloud-build:
docker-compose build nextcloud-app
docker build -f nextcloud/Dockerfile -t $(NEXTCLOUD) ./nextcloud
nextcloud-push:
docker-compose push nextcloud-app
docker push $(NEXTCLOUD)
nextcloud-pull:
docker-compose pull nextcloud-app
docker pull $(NEXTCLOUD)
nextcloud: nextcloud-clean nextcloud-build nextcloud-push
# -----------------------------------------------------------------------------
# proxy
# -----------------------------------------------------------------------------
proxy-clean:
docker rmi $(DOCKER_REGISTRY)/proxy || /bin/true
proxy-build:
docker-compose build proxy
proxy-push:
docker-compose push proxy
proxy-pull:
docker-compose pull proxy
proxy: proxy-clean proxy-build proxy-push
# -----------------------------------------------------------------------------
# runners
# -----------------------------------------------------------------------------
# base ------------------------------------------------------------------------
runner-base-clean:
docker rmi $(DOCKER_REGISTRY)/runner-base || /bin/true
runner-base-build:
docker build -f runner/Dockerfile \
-t $(DOCKER_REGISTRY)/runner-base \
./runner
runner-base-push:
docker push $(DOCKER_REGISTRY)/runner-base
runner-base-pull:
docker pull $(DOCKER_REGISTRY)/runner-base
runner-base: runner-base-clean runner-base-build runner-base-push
# main ------------------------------------------------------------------------
runner-main-clean:
docker rmi $(DOCKER_REGISTRY)/runner-main || /bin/true
runner-main-build: runner-base-build
docker-compose build runner-main
runner-main-push:
docker-compose push runner-main
runner-main-pull:
docker-compose pull runner-main
runner-main: runner-main-clean runner-main-build runner-main-push
# docker ----------------------------------------------------------------------
runner-docker-clean:
docker rmi $(DOCKER_REGISTRY)/runner-docker || /bin/true
runner-docker-build: runner-base-build
docker-compose build runner-docker
runner-docker-push:
docker-compose push runner-docker
runner-docker-pull:
docker-compose pull runner-docker
runner-docker: runner-docker-clean runner-docker-build runner-docker-push
# collect ---------------------------------------------------------------------
runners-clean: \
runner-base-clean \
runner-main-clean \
runner-docker-clean
runners-build: \
runner-base-build \
runner-main-build \
runner-docker-build
runners-push: \
runner-main-push \
runner-docker-push
runners-pull: \
runner-main-pull \
runner-docker-pull
runners: runners-clean runners-build runners-push
# -----------------------------------------------------------------------------
# Collect targets.
# -----------------------------------------------------------------------------
@ -163,21 +93,24 @@ clean-all:
docker image prune -a -f
clean-builds: \
wiki-clean \
nextcloud-clean \
proxy-clean \
runner-base-clean \
runner-main-clean \
runner-docker-clean
wiki-clean \
nextcloud-clean
build-all: runner-base-build
docker-compose build
build-all: \
proxy-build \
wiki-build \
nextcloud-build
push-all:
docker-compose push
push-all: \
proxy-push \
wiki-push \
nextcloud-push
pull-all:
docker-compose pull
pull-all: \
proxy-pull \
wiki-pull \
nextcloud-pull
# -----------------------------------------------------------------------------
# Clean - build - push

View File

@ -8,11 +8,7 @@ volumes:
gitlab_logs:
gitlab_data:
letsencrypt:
runner_main_etc:
runner_main_home:
runner_docker_etc:
runner_docker_home:
docker_dind_lib:
runner_0:
services:
@ -93,7 +89,7 @@ services:
registry_nginx['listen_https'] = false
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '2770:22'
- 2770:22
volumes:
- gitlab_config:/etc/gitlab
- gitlab_logs:/var/log/gitlab
@ -127,32 +123,13 @@ services:
# Gitlab runners for CI.
# ---------------------------------------------------------------------------
runner-main:
# See https://docs.gitlab.com/ee/ci/docker/using_docker_build.html for how to
# register the runner for running docker-in-docker builds. Note the need to
# set docker-privileged.
runner-0:
container_name: runner-main
build: runner/main
image: registry.wojciechkozlowski.eu/wojtek/loki/runner-main
image: gitlab/gitlab-runner
volumes:
- runner_main_etc:/etc/gitlab-runner
- runner_main_home:/home/gitlab-runner
- runner_0:/etc/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
restart: always
docker-dind:
container_name: docker-dind
image: docker:dind
volumes:
- ./runner/docker/hosts:/etc/hosts
- docker_dind_lib:/var/lib/docker
privileged: true
restart: always
runner-docker:
container_name: runner-docker
build: runner/docker
image: registry.wojciechkozlowski.eu/wojtek/loki/runner-docker
links:
- docker-dind:docker
volumes:
- runner_docker_etc:/etc/gitlab-runner
- runner_docker_home:/home/gitlab-runner
restart: always

View File

@ -15,7 +15,7 @@ DIRNAME=$(dirname $SCRIPT)
echo -e "${CYAN}[${SCRIPT}] Pull updated images${NC}"
make -C $DIRNAME pull-all
make -f $DIRNAME/docker-compose.yml pull
# -----------------------------------------------------------------------------
# Stop the containers.