Loading .gitlab-ci.yml +32 −10 Original line number Diff line number Diff line image: docker:latest stages: - build - push - cleanup variables: DOCKER_DRIVER: overlay before_script: - export APP_IMAGE="ttree/phpbu" services: - docker:dind - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - export VCS_REF=`git rev-parse --short HEAD` before_script: - docker info - export ISOLATION=pipeline_${CI_PIPELINE_ID} - export COMPOSE_PROJECT_NAME=${ISOLATION} - pwd - docker version - docker-compose version - echo "Start processing ${APP_VERSION} in ${ISOLATION}" build: stage: build script: - docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` -t ttree/phpbu:4.0.6 . - docker tag ttree/phpbu:4.0.6 ttree/phpbu:4.0 - docker tag ttree/phpbu:4.0.6 ttree/phpbu:latest - make build push_app: stage: push script: - docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" - docker tag ${ISOLATION}_app ${APP_IMAGE}:${CI_COMMIT_TAG} - docker push ${APP_IMAGE}:${CI_COMMIT_TAG} only: - tags cleanup: stage: cleanup when: always script: - make clean - docker ps -f name=${ISOLATION} Makefile +1 −9 Original line number Diff line number Diff line build: docker build -t ttree/phpbu:4.0.6 . docker tag ttree/phpbu:4.0.6 ttree/phpbu:4.0 docker tag ttree/phpbu:4.0.6 ttree/phpbu:latest push: docker push ttree/phpbu:4.0.6 docker push ttree/phpbu:4.0 docker push ttree/phpbu:latest include ./Makefile.base Makefile.base 0 → 100644 +42 −0 Original line number Diff line number Diff line DOCKER_COMPOSE ?= docker-compose DOCKER_HOST ?= localhost # Targets # ------- default: help build: ##@base build images in test-stack $(shell echo $(shell git describe --long --tags --dirty --always) > ../src/version) @echo $(shell cat ../src/version) $(DOCKER_COMPOSE) build --pull up: ##@base start stack $(DOCKER_COMPOSE) up -d clean: ##@base remove all containers in stack $(DOCKER_COMPOSE) kill $(DOCKER_COMPOSE) rm -fv --all $(DOCKER_COMPOSE) down --remove-orphans # Help based on https://gist.github.com/prwhite/8168133 thanks to @nowox and @prwhite # And add help text after each target name starting with '\#\#' # A category can be added with @category HELP_FUN = \ %help; \ while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([\w-]+)\s*:.*\#\#(?:@([\w-]+))?\s(.*)$$/ }; \ print "\nusage: make [target ...]\n\n"; \ for (keys %help) { \ print "$$_:\n"; \ for (@{$$help{$$_}}) { \ $$sep = "." x (25 - length $$_->[0]); \ print " $$_->[0]$$sep$$_->[1]\n"; \ } \ print "\n"; } help: ##@system show this help # # General targets # @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST) docker-compose.yml 0 → 100644 +10 −0 Original line number Diff line number Diff line version: "2" services: app: build: context: . dockerfile: Dockerfile args: - BUILD_DATE=${BUILD_DATE} - VCS_REF=${VCS_REF} Loading
.gitlab-ci.yml +32 −10 Original line number Diff line number Diff line image: docker:latest stages: - build - push - cleanup variables: DOCKER_DRIVER: overlay before_script: - export APP_IMAGE="ttree/phpbu" services: - docker:dind - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - export VCS_REF=`git rev-parse --short HEAD` before_script: - docker info - export ISOLATION=pipeline_${CI_PIPELINE_ID} - export COMPOSE_PROJECT_NAME=${ISOLATION} - pwd - docker version - docker-compose version - echo "Start processing ${APP_VERSION} in ${ISOLATION}" build: stage: build script: - docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` -t ttree/phpbu:4.0.6 . - docker tag ttree/phpbu:4.0.6 ttree/phpbu:4.0 - docker tag ttree/phpbu:4.0.6 ttree/phpbu:latest - make build push_app: stage: push script: - docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" - docker tag ${ISOLATION}_app ${APP_IMAGE}:${CI_COMMIT_TAG} - docker push ${APP_IMAGE}:${CI_COMMIT_TAG} only: - tags cleanup: stage: cleanup when: always script: - make clean - docker ps -f name=${ISOLATION}
Makefile +1 −9 Original line number Diff line number Diff line build: docker build -t ttree/phpbu:4.0.6 . docker tag ttree/phpbu:4.0.6 ttree/phpbu:4.0 docker tag ttree/phpbu:4.0.6 ttree/phpbu:latest push: docker push ttree/phpbu:4.0.6 docker push ttree/phpbu:4.0 docker push ttree/phpbu:latest include ./Makefile.base
Makefile.base 0 → 100644 +42 −0 Original line number Diff line number Diff line DOCKER_COMPOSE ?= docker-compose DOCKER_HOST ?= localhost # Targets # ------- default: help build: ##@base build images in test-stack $(shell echo $(shell git describe --long --tags --dirty --always) > ../src/version) @echo $(shell cat ../src/version) $(DOCKER_COMPOSE) build --pull up: ##@base start stack $(DOCKER_COMPOSE) up -d clean: ##@base remove all containers in stack $(DOCKER_COMPOSE) kill $(DOCKER_COMPOSE) rm -fv --all $(DOCKER_COMPOSE) down --remove-orphans # Help based on https://gist.github.com/prwhite/8168133 thanks to @nowox and @prwhite # And add help text after each target name starting with '\#\#' # A category can be added with @category HELP_FUN = \ %help; \ while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([\w-]+)\s*:.*\#\#(?:@([\w-]+))?\s(.*)$$/ }; \ print "\nusage: make [target ...]\n\n"; \ for (keys %help) { \ print "$$_:\n"; \ for (@{$$help{$$_}}) { \ $$sep = "." x (25 - length $$_->[0]); \ print " $$_->[0]$$sep$$_->[1]\n"; \ } \ print "\n"; } help: ##@system show this help # # General targets # @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
docker-compose.yml 0 → 100644 +10 −0 Original line number Diff line number Diff line version: "2" services: app: build: context: . dockerfile: Dockerfile args: - BUILD_DATE=${BUILD_DATE} - VCS_REF=${VCS_REF}