From 05dfb923b37b6ebc4e143e2e5d20f0de5f1b548c Mon Sep 17 00:00:00 2001 From: Alexander <326840+beeyev@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:16:57 +0200 Subject: [PATCH 1/2] small refactor --- .../actions/prepare-env-variables/action.yml | 27 +++++++++ .../workflows/callable-build-docker-image.yml | 60 +++++++++++++++++++ .../manual-delete-old-workflow-runs.yml | 58 ++++++++++++++++++ .../workflows/pr-build-test-docker-image.yml | 43 +++++++++++++ docker/Dockerfile | 41 +++++++------ docker/config/caddy/Caddyfile | 2 +- docker/etc/docker-entrypoint.sh | 11 +++- 7 files changed, 220 insertions(+), 22 deletions(-) create mode 100644 .github/actions/prepare-env-variables/action.yml create mode 100644 .github/workflows/callable-build-docker-image.yml create mode 100644 .github/workflows/manual-delete-old-workflow-runs.yml create mode 100644 .github/workflows/pr-build-test-docker-image.yml diff --git a/.github/actions/prepare-env-variables/action.yml b/.github/actions/prepare-env-variables/action.yml new file mode 100644 index 0000000..e00a4eb --- /dev/null +++ b/.github/actions/prepare-env-variables/action.yml @@ -0,0 +1,27 @@ +# Alexander Tebiev - https://github.com/beeyev +name: Prepare Docker env variables +description: 'Prepare env variables' +outputs: + DATE_YEAR_WEEKNUM: + description: "DATE_YEAR_WEEKNUM" + value: ${{ steps.prepare-env-variables.outputs.DATE_YEAR_WEEKNUM }} + BUILD_DATE: + description: "BUILD_DATE" + value: ${{ steps.prepare-env-variables.outputs.BUILD_DATE }} + BUILD_FINGERPRINT: + description: "BUILD_FINGERPRINT" + value: ${{ steps.prepare-env-variables.outputs.BUILD_FINGERPRINT }} + CURRENT_BRANCH_NAME: + description: "CURRENT_BRANCH_NAME" + value: ${{ steps.prepare-env-variables.outputs.CURRENT_BRANCH_NAME }} +runs: + using: "composite" + steps: + - id: prepare-env-variables + shell: bash + run: | + echo "DATE_YEAR_WEEKNUM=$(TZ=':UTC' date +'%Y-%U')" >> ${GITHUB_OUTPUT} + echo "BUILD_DATE=$(date -u +'%Y-%m-%d %H:%M:%S (%Z)')" >> ${GITHUB_OUTPUT} + echo "NOW_RFC_3339=$(date -u --rfc-3339=seconds | sed 's/ /T/')" >> ${GITHUB_OUTPUT} + echo "BUILD_FINGERPRINT=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT} + echo "CURRENT_BRANCH_NAME=$(git branch --show-current)" >> ${GITHUB_OUTPUT} diff --git a/.github/workflows/callable-build-docker-image.yml b/.github/workflows/callable-build-docker-image.yml new file mode 100644 index 0000000..190e02a --- /dev/null +++ b/.github/workflows/callable-build-docker-image.yml @@ -0,0 +1,60 @@ +# Alexander Tebiev - https://github.com/beeyev +on: + workflow_call: + inputs: + DOCKER_REGISTRY_IMAGE: + required: true + type: string + DOCKERFILE_PATH: + required: true + type: string + BASE_IMAGE_VERSION: + required: true + type: string + +jobs: + build-docker-image: + name: Build Docker Image + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + steps: + - name: Checkout branch - ${{ github.head_ref || github.ref_name }} + uses: actions/checkout@v3 + + - name: Prepare Build Env Variables + uses: ./.github/actions/prepare-env-variables/ + id: prepare-build-env-variables + + - 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 image and push to registry - ${{ inputs.DOCKER_REGISTRY_IMAGE }} + uses: docker/build-push-action@v4 + with: + platforms: linux/amd64 + context: . + file: ${{ inputs.DOCKERFILE_PATH }} + cache-from: type=registry,ref=${{ inputs.DOCKER_REGISTRY_IMAGE }} + cache-to: type=inline + build-args: | + BASE_IMAGE_VERSION=${{ inputs.BASE_IMAGE_VERSION }} + BUILD_DATE=${{ steps.prepare-build-env-variables.outputs.BUILD_DATE }} + BUILD_FINGERPRINT=${{ steps.prepare-build-env-variables.outputs.BUILD_FINGERPRINT }} + BRANCH_NAME=${{ steps.prepare-build-env-variables.outputs.CURRENT_BRANCH_NAME }} + tags: ${{ inputs.DOCKER_REGISTRY_IMAGE }} + push: true diff --git a/.github/workflows/manual-delete-old-workflow-runs.yml b/.github/workflows/manual-delete-old-workflow-runs.yml new file mode 100644 index 0000000..fb56344 --- /dev/null +++ b/.github/workflows/manual-delete-old-workflow-runs.yml @@ -0,0 +1,58 @@ +# Alexander Tebiev - https://github.com/beeyev +name: Delete old workflow runs +on: + workflow_dispatch: + inputs: + days: + description: 'Number of days.' + required: true + default: 30 + minimum_runs: + description: 'The minimum runs to keep for each workflow.' + required: true + default: 6 + delete_workflow_pattern: + description: 'The name or filename of the workflow. if not set then it will target all workflows.' + required: false + delete_workflow_by_state_pattern: + description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' + required: true + default: "All" + type: choice + options: + - "All" + - active + - deleted + - disabled_inactivity + - disabled_manually + delete_run_by_conclusion_pattern: + description: 'Remove workflow by conclusion: action_required, cancelled, failure, skipped, success' + required: true + default: "All" + type: choice + options: + - "All" + - action_required + - cancelled + - failure + - skipped + - success + dry_run: + description: 'Only log actions, do not perform any delete operations.' + required: false + +jobs: + del_runs: + runs-on: ubuntu-latest + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: ${{ github.event.inputs.days }} + keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} + delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} + delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} + delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern }} + dry_run: ${{ github.event.inputs.dry_run }} diff --git a/.github/workflows/pr-build-test-docker-image.yml b/.github/workflows/pr-build-test-docker-image.yml new file mode 100644 index 0000000..6e926a6 --- /dev/null +++ b/.github/workflows/pr-build-test-docker-image.yml @@ -0,0 +1,43 @@ +# Alexander Tebiev - https://github.com/beeyev +name: Build Test Docker Images + +on: + pull_request: + types: [labeled] + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + initialization: + name: Initialization + runs-on: ubuntu-latest + permissions: + pull-requests: write + if: contains(github.event.label.name, 'make-test-build') +# if: | +# (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: + message: | + > [Building test docker images...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + docker-image-deploy: + uses: ./.github/workflows/callable-build-docker-image.yml + name: Build Test Docker Images / ${{ matrix.baseDist }}-test + with: + BASE_IMAGE_VERSION: 5.2-fpm-alpine + DOCKER_REGISTRY_IMAGE: ghcr.io/beeyev/phpmyadmin-docker-lightweight:test + DOCKERFILE_PATH: ./docker/Dockerfile + secrets: inherit diff --git a/docker/Dockerfile b/docker/Dockerfile index 1ea2556..d9527d5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,6 @@ -# docker build -t phpmyadmin-fpm-alpine-caddy --build-arg BUILDKIT_INLINE_CACHE=1 -f ./docker/Dockerfile . && docker run --rm -it -p 8080:80 phpmyadmin-fpm-alpine-caddy +# syntax=docker/dockerfile:1 +# Author: Alexander Tebiev - https://github.com/beeyev/phpmyadmin-docker-lightweight +# docker buildx build --build-arg=BASE_IMAGE_VERSION=5.2-fpm-alpine --cache-to=type=inline --pull --tag phpmyadmin-fpm-alpine-caddy --file ./docker/Dockerfile ./ && docker run -p 9090:80 -it --rm phpmyadmin-fpm-alpine-caddy ARG BASE_IMAGE_VERSION FROM phpmyadmin:${BASE_IMAGE_VERSION} as phpmyadmin @@ -9,7 +11,10 @@ RUN set -eux \ curl \ unzip \ && curl -fsSL https://github.com/phpmyadmin/themes/archive/refs/heads/master.zip --output /src/phpmyadmin-themes.zip \ - && unzip -uoq /src/phpmyadmin-themes.zip -d /src/ + && unzip -uoq /src/phpmyadmin-themes.zip -d /src/ \ + && mkdir /src/selected-themes/ \ + && cp -r /src/themes-master/blueberry/ /src/themes-master/boodark/ -t /src/selected-themes/ + FROM phpmyadmin @@ -19,8 +24,8 @@ LANG="en_US.UTF-8" \ LC_TIME="en_DK.UTF-8" \ TIME_STYLE="long-iso" -RUN set -eux \ - && apk add --quiet --no-cache \ +RUN --mount=type=cache,sharing=locked,target=/var/cache/apk/ set -eux \ + && apk add --quiet --update --no-cache \ iputils \ # `fcgi` - Healthcheck | https://github.com/renatomefi/php-fpm-healthcheck fcgi \ @@ -29,27 +34,26 @@ RUN set -eux \ # Caddy | https://caddyserver.com/ COPY --from=caddy:2-alpine /usr/bin/caddy /usr/local/bin/caddy COPY ./docker/config/caddy/Caddyfile /etc/caddy/Caddyfile +ENV ACME_AGREE=true RUN set -eux \ -# && setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy \ - && caddy fmt --overwrite /etc/caddy/Caddyfile \ + && caddy validate --config /etc/caddy/Caddyfile \ && caddy version -# Healthcheck | https://github.com/renatomefi/php-fpm-healthcheck +## Healthcheck | https://github.com/renatomefi/php-fpm-healthcheck +ADD --chmod=0705 --link https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck /usr/local/bin/php-fpm-healthcheck RUN set -eux \ - && curl -fsSL https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck --output /usr/local/bin/php-fpm-healthcheck \ - && chmod +x /usr/local/bin/php-fpm-healthcheck \ && echo "pm.status_path = /status" >> /usr/local/etc/php-fpm.d/zz-docker.conf -HEALTHCHECK --interval=1m --timeout=1s --start-period=10s CMD (curl --fail http://localhost/LICENSE && php-fpm-healthcheck) || exit 1 +# Cheching Caddy & php-fpm +HEALTHCHECK --interval=1m --timeout=1s --start-period=10s CMD (curl --fail http://localhost:9999/health && php-fpm-healthcheck) || exit 1 COPY ./docker/config/php-fpm.d/zzz-php-fpm_custom.conf /usr/local/etc/php-fpm.d/zzz-php-fpm_custom.conf # Install themes -COPY --from=phpmyadmin-themes /src/themes-master/blueberry/ /var/www/html/themes/blueberry/ -COPY --from=phpmyadmin-themes /src/themes-master/boodark/ /var/www/html/themes/boodark/ +COPY --from=phpmyadmin-themes /src/selected-themes/ /var/www/html/themes/ LABEL org.opencontainers.image.title="phpMyAdmin Docker image" \ org.opencontainers.image.description="Run phpMyAdmin with Alpine, PHP FPM and Caddy" \ - org.opencontainers.image.authors="https://github.com/beeyev/phpmyadmin-docker-lightweight" \ + org.opencontainers.image.authors="https://github.com/beeyev/" \ org.opencontainers.image.vendor="phpMyAdmin" \ org.opencontainers.image.documentation="https://github.com/beeyev/phpmyadmin-docker-lightweight" \ org.opencontainers.image.url="https://github.com/beeyev/phpmyadmin-docker-lightweight" \ @@ -59,15 +63,15 @@ ARG TZ='UTC' ENV TZ=$TZ #These params meant to be set by CI -ARG IMAGE_TAG -ENV IMAGE_TAG=$IMAGE_TAG -RUN echo $IMAGE_TAG -ARG BUILD_DATE +ARG BUILD_DATE=undefined ENV BUILD_DATE=$BUILD_DATE RUN echo $BUILD_DATE -ARG BUILD_FINGERPRINT +ARG BUILD_FINGERPRINT=undefined ENV BUILD_FINGERPRINT=$BUILD_FINGERPRINT RUN echo $BUILD_FINGERPRINT +ARG BRANCH_NAME=undefined +ENV BRANCH_NAME=$BRANCH_NAME +RUN echo $BRANCH_NAME RUN set -eux \ && mv /docker-entrypoint.sh /phpmyadmin-docker-entrypoint.sh @@ -75,4 +79,3 @@ RUN set -eux \ COPY --chmod=0755 ./docker/etc/docker-entrypoint.sh /docker-entrypoint.sh ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] EXPOSE 80 - diff --git a/docker/config/caddy/Caddyfile b/docker/config/caddy/Caddyfile index afa9b5b..45cd4f5 100644 --- a/docker/config/caddy/Caddyfile +++ b/docker/config/caddy/Caddyfile @@ -15,6 +15,6 @@ php_fastcgi 127.0.0.1:9000 { trusted_proxies 0.0.0.0/0 } - file_server browse + file_server encode zstd gzip } diff --git a/docker/etc/docker-entrypoint.sh b/docker/etc/docker-entrypoint.sh index d51c153..7f37773 100644 --- a/docker/etc/docker-entrypoint.sh +++ b/docker/etc/docker-entrypoint.sh @@ -20,9 +20,16 @@ for f in /docker-entrypoint.init.d/*; do esac done -printf "\n${GRN}--->${NC} 🚀️️ Welcome to ${GRN}beeyev phpMyAdmin v.${VERSION} lightweight${NC} container..." +printf "\n${GRN}--->${NC} 🚀 Starting ${GRN}beeyev phpMyAdmin v.${VERSION} lightweight${NC} container..." printf "\n${GRN}--->${NC} Docker image build date: ${GRN}${BUILD_DATE}${NC}, fingerprint: ${GRN}${BUILD_FINGERPRINT}${NC}" -printf "\n${GRN}--->${NC} Subscribe to project updates: ${GRN}https://github.com/beeyev/phpmyadmin-docker-lightweight${NC}\n\n" +printf "\n${GRN}--->${NC} Subscribe to the project updates: ${GRN}https://github.com/beeyev/phpmyadmin-docker-lightweight${NC}" + +printf "\n\nCaddy version:\n" +caddy version + +printf "\nPHP-FPM version:\n" +php-fpm --version +printf "\n" caddy start --adapter caddyfile --config /etc/caddy/Caddyfile From 10bea305cff6e3355de123b3ff0239fdc4bba6ca Mon Sep 17 00:00:00 2001 From: Alexander <326840+beeyev@users.noreply.github.com> Date: Mon, 28 Aug 2023 21:31:02 +0200 Subject: [PATCH 2/2] small refactor --- .github/workflows/main.yml | 90 ------------------- .../merge-build-production-docker-images.yml | 50 +++++++++++ .../workflows/pr-build-test-docker-image.yml | 27 ++++-- Makefile | 55 +++++++++--- docker-compose.yml | 6 +- docker/etc/docker-entrypoint.sh | 1 + 6 files changed, 116 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/merge-build-production-docker-images.yml 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