small refactor

This commit is contained in:
Alexander
2023-08-28 16:23:41 +02:00
parent 4bc01a9ab0
commit 05dfb923b3
7 changed files with 220 additions and 22 deletions
@@ -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}
@@ -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
@@ -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 }}
@@ -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
+22 -19
View File
@@ -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
+1 -1
View File
@@ -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
}
+9 -2
View File
@@ -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