small refactor

This commit is contained in:
Alexander
2023-08-28 22:11:26 +02:00
parent 05dfb923b3
commit 10bea305cf
6 changed files with 116 additions and 113 deletions
-90
View File
@@ -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 }}
@@ -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 }}
@@ -22,11 +22,6 @@ jobs:
# (github.event.action == 'labeled' && github.event.label.name == 'make-test-build') || # (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')) # (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'make-test-build'))
steps: steps:
- name: Remove `test-build` label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: make-test-build
- name: Sticky Pull Request Comment - name: Sticky Pull Request Comment
uses: marocchino/sticky-pull-request-comment@v2 uses: marocchino/sticky-pull-request-comment@v2
with: with:
@@ -34,10 +29,28 @@ jobs:
> [Building test docker images...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) > [Building test docker images...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
docker-image-deploy: 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 uses: ./.github/workflows/callable-build-docker-image.yml
name: Build Test Docker Images / ${{ matrix.baseDist }}-test name: Build Test Docker Images / ${{ matrix.baseDist }}-test
if: contains(github.event.label.name, 'make-test-build')
with: with:
BASE_IMAGE_VERSION: 5.2-fpm-alpine BASE_IMAGE_VERSION: ${{ matrix.SOURCE_IMAGE_VERSION }}
DOCKER_REGISTRY_IMAGE: ghcr.io/beeyev/phpmyadmin-docker-lightweight:test DOCKER_REGISTRY_IMAGE: ghcr.io/beeyev/phpmyadmin-docker-lightweight:${{ matrix.TARGET_IMAGE_VERSION }}
DOCKERFILE_PATH: ./docker/Dockerfile DOCKERFILE_PATH: ./docker/Dockerfile
secrets: inherit 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
+41 -14
View File
@@ -1,27 +1,54 @@
THIS_FILE := $(abspath $(lastword $(MAKEFILE_LIST))) # Alexander Tebiev - https://github.com/beeyev
CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
up: .EXPORT_ALL_VARIABLES:
docker-compose up --build --no-deps --detach --remove-orphans .PHONY: *
.DEFAULT_GOAL := help
down: ifeq (,$(shell command docker compose 2> /dev/null))
docker-compose down --remove-orphans DOCKER_COMPOSE_COMMAND = docker-compose
else
DOCKER_COMPOSE_COMMAND = docker compose
endif
stop: help: ## Show this help
docker-compose stop @echo "Make Application Docker Images and Containers using Docker-Compose files in 'docker' Dir."
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
update: up: ## Docker compose up
docker-compose pull $(DOCKER_COMPOSE_COMMAND) up --build --no-deps --detach --remove-orphans
start:
make up 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) $(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 docker ps --format=table
logs: ## Show docker logs logs: ## Show docker logs
docker-compose logs -f --tail=100 $(ARGS) $(DOCKER_COMPOSE_COMMAND) logs -f --tail=100 $(ARGS)
phpmyadmin: phpmyadmin:
docker-compose exec phpmyadmin bash $(DOCKER_COMPOSE_COMMAND) exec phpmyadmin bash
@printf "\n http://localhost:8080/ \n"
+4 -2
View File
@@ -1,8 +1,8 @@
version: "3" # Alexander Tebiev - https://github.com/beeyev
services: services:
phpmyadmin: phpmyadmin:
image: beeyev/phpmyadmin-lightweight:latest image: ghcr.io/beeyev/phpmyadmin-docker-lightweight:test
container_name: 'phpmyadmin' container_name: 'phpmyadmin'
restart: unless-stopped restart: unless-stopped
tty: true tty: true
@@ -13,6 +13,8 @@ services:
- 'PMA_PASSWORD=TestRootPassword' - 'PMA_PASSWORD=TestRootPassword'
ports: ports:
- '8080:80' - '8080:80'
depends_on:
- mysql
networks: networks:
- network1 - network1
+1
View File
@@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# Alexander Tebiev - https://github.com/beeyev
#String Colors #String Colors
NC='\033[0;m' # Default Color NC='\033[0;m' # Default Color