diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 894f834..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - - schedule: - - cron: "23 1 2 * *" - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - - build-gearman: - name: Build, test and publish - ${{ matrix.release_image_version }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - base_image_version: [ '5.2-fpm-alpine', 'fpm-alpine' ] - include: - - base_image_version: '5.2-fpm-alpine' - release_image_version: '5.2' - - base_image_version: 'fpm-alpine' - release_image_version: 'latest' - - steps: - - name: Prepare env variables - run: | - echo "BUILD_DATE=$(TZ=':UTC' date +'%Y-%m-%d %H:%M:%S (%Z)')" >> ${GITHUB_ENV} - echo "BUILD_FINGERPRINT=${GITHUB_SHA::7}" >> ${GITHUB_ENV} - - - name: Check out code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GH_TOKEN }} - - - name: Build images and push to registry - uses: docker/build-push-action@v4 - with: - platforms: linux/amd64 - cache-from: type=gha, scope=${{ github.workflow }}-${{ matrix.version }} - cache-to: type=gha, scope=${{ github.workflow }}-${{ matrix.version }}, mode=max - context: . - file: ./docker/Dockerfile - build-args: | - BUILD_DATE=${{ env.BUILD_DATE }} - BUILD_FINGERPRINT=${{ env.BUILD_FINGERPRINT }} - BASE_IMAGE_VERSION=${{ matrix.base_image_version }} - IMAGE_TAG=${{ matrix.release_image_version }} - tags: | - beeyev/phpmyadmin-lightweight:${{ matrix.release_image_version }} - ghcr.io/beeyev/phpmyadmin-docker-lightweight:${{ matrix.release_image_version }} - pull: true - push: true - - - Update-Docker-Hub-repo-description: - name: Update Docker Hub repo description - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v3 - - - name: Update Docker Hub repo description - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - repository: beeyev/phpmyadmin-lightweight - #short-description: ${{ github.event.repository.description }} diff --git a/.github/workflows/merge-build-production-docker-images.yml b/.github/workflows/merge-build-production-docker-images.yml new file mode 100644 index 0000000..0053438 --- /dev/null +++ b/.github/workflows/merge-build-production-docker-images.yml @@ -0,0 +1,50 @@ +# Alexander Tebiev - https://github.com/beeyev +name: Build Production Docker Images + +on: + push: + branches: [ master ] + + schedule: + - cron: "23 1 2 * *" + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + docker-image-deploy: + strategy: + fail-fast: false + matrix: + SOURCE_IMAGE_VERSION: [ '5.2-fpm-alpine' ] + TARGET_IMAGE_VERSION: [ '5.2' ] + uses: ./.github/workflows/callable-build-docker-image.yml + name: Build Production Docker Images / ${{ matrix.SOURCE_IMAGE_VERSION }}-${{ matrix.TARGET_IMAGE_VERSION }} + with: + BASE_IMAGE_VERSION: ${{ matrix.SOURCE_IMAGE_VERSION }} + DOCKER_REGISTRY_IMAGE: | + beeyev/phpmyadmin-lightweight:latest + beeyev/phpmyadmin-lightweight:${{ matrix.TARGET_IMAGE_VERSION }} + ghcr.io/beeyev/phpmyadmin-docker-lightweight:latest + ghcr.io/beeyev/phpmyadmin-docker-lightweight:${{ matrix.TARGET_IMAGE_VERSION }} + DOCKERFILE_PATH: ./docker/Dockerfile + secrets: inherit + + update-docker-hub-repo-description: + name: Update Docker Hub repo description + runs-on: ubuntu-latest + needs: docker-image-deploy + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Update Docker Hub repo description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: beeyev/phpmyadmin-lightweight + #short-description: ${{ github.event.repository.description }} diff --git a/.github/workflows/pr-build-test-docker-image.yml b/.github/workflows/pr-build-test-docker-image.yml index 6e926a6..a909864 100644 --- a/.github/workflows/pr-build-test-docker-image.yml +++ b/.github/workflows/pr-build-test-docker-image.yml @@ -22,11 +22,6 @@ jobs: # (github.event.action == 'labeled' && github.event.label.name == 'make-test-build') || # (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'make-test-build')) steps: - - name: Remove `test-build` label - uses: actions-ecosystem/action-remove-labels@v1 - with: - labels: make-test-build - - name: Sticky Pull Request Comment uses: marocchino/sticky-pull-request-comment@v2 with: @@ -34,10 +29,28 @@ jobs: > [Building test docker images...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) docker-image-deploy: + strategy: + fail-fast: false + matrix: + SOURCE_IMAGE_VERSION: [ '5.2-fpm-alpine' ] + TARGET_IMAGE_VERSION: [ 'test' ] uses: ./.github/workflows/callable-build-docker-image.yml name: Build Test Docker Images / ${{ matrix.baseDist }}-test + if: contains(github.event.label.name, 'make-test-build') with: - BASE_IMAGE_VERSION: 5.2-fpm-alpine - DOCKER_REGISTRY_IMAGE: ghcr.io/beeyev/phpmyadmin-docker-lightweight:test + BASE_IMAGE_VERSION: ${{ matrix.SOURCE_IMAGE_VERSION }} + DOCKER_REGISTRY_IMAGE: ghcr.io/beeyev/phpmyadmin-docker-lightweight:${{ matrix.TARGET_IMAGE_VERSION }} DOCKERFILE_PATH: ./docker/Dockerfile secrets: inherit + + finalize: + name: Finalize + runs-on: ubuntu-latest + permissions: + pull-requests: write + needs: docker-image-deploy + steps: + - name: Remove `test-build` label + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: make-test-build diff --git a/Makefile b/Makefile index e7a61bf..6738f4c 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,54 @@ -THIS_FILE := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +# Alexander Tebiev - https://github.com/beeyev -up: - docker-compose up --build --no-deps --detach --remove-orphans +.EXPORT_ALL_VARIABLES: +.PHONY: * +.DEFAULT_GOAL := help -down: - docker-compose down --remove-orphans +ifeq (,$(shell command docker compose 2> /dev/null)) + DOCKER_COMPOSE_COMMAND = docker-compose +else + DOCKER_COMPOSE_COMMAND = docker compose +endif -stop: - docker-compose stop +help: ## Show this help + @echo "Make Application Docker Images and Containers using Docker-Compose files in 'docker' Dir." + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) -update: - docker-compose pull +up: ## Docker compose up + $(DOCKER_COMPOSE_COMMAND) up --build --no-deps --detach --remove-orphans + +start: make up -restart: down up +down: ## Docker compose down + $(DOCKER_COMPOSE_COMMAND) down --remove-orphans + +stop: ## Docker compose stop + $(DOCKER_COMPOSE_COMMAND) stop + +restart: ## Restart containers + make down + make up $(info Restart completed) -state: +update: ## Update containers + $(DOCKER_COMPOSE_COMMAND) pull + make up + +destroy: ## Destroy containers/volumes (keep sources app folders) + make stop + $(DOCKER_COMPOSE_COMMAND) down --rmi all --remove-orphans + +rebuild: ## Rebuild docker container (destroy & upgrade) + make destroy + make up + +state: ## Show current state docker ps --format=table logs: ## Show docker logs - docker-compose logs -f --tail=100 $(ARGS) + $(DOCKER_COMPOSE_COMMAND) logs -f --tail=100 $(ARGS) phpmyadmin: - docker-compose exec phpmyadmin bash + $(DOCKER_COMPOSE_COMMAND) exec phpmyadmin bash + @printf "\n http://localhost:8080/ \n" diff --git a/docker-compose.yml b/docker-compose.yml index 17f8523..bebb3c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ -version: "3" +# Alexander Tebiev - https://github.com/beeyev services: phpmyadmin: - image: beeyev/phpmyadmin-lightweight:latest + image: ghcr.io/beeyev/phpmyadmin-docker-lightweight:test container_name: 'phpmyadmin' restart: unless-stopped tty: true @@ -13,6 +13,8 @@ services: - 'PMA_PASSWORD=TestRootPassword' ports: - '8080:80' + depends_on: + - mysql networks: - network1 diff --git a/docker/etc/docker-entrypoint.sh b/docker/etc/docker-entrypoint.sh index 7f37773..48c0591 100644 --- a/docker/etc/docker-entrypoint.sh +++ b/docker/etc/docker-entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/sh +# Alexander Tebiev - https://github.com/beeyev #String Colors NC='\033[0;m' # Default Color