From c022086e931e2f1bc487dab177ff1833a059d8a1 Mon Sep 17 00:00:00 2001 From: Aditya Prima Date: Sun, 24 Mar 2024 03:42:16 +0700 Subject: [PATCH] Added gitea workflows --- .gitea/workflows/alpine-dockerio.yaml | 125 ++++++++++++++++++++++++++ .gitea/workflows/alpine-winter.yaml | 117 ++++++++++++++++++++++++ .gitea/workflows/ubuntu-dockerio.yaml | 119 ++++++++++++++++++++++++ .gitea/workflows/ubuntu-winter.yaml | 111 +++++++++++++++++++++++ Dockerfile.alpine | 32 +++++++ Dockerfile.ubuntu | 33 +++++++ etc/php/fpm/php-fpm.conf | 18 ++++ etc/php/fpm/pool.d/00-www.conf | 55 ++++++++++++ scripts/php-fpm-init | 5 ++ scripts/php-fpm-init-alpine | 5 ++ 10 files changed, 620 insertions(+) create mode 100644 .gitea/workflows/alpine-dockerio.yaml create mode 100644 .gitea/workflows/alpine-winter.yaml create mode 100644 .gitea/workflows/ubuntu-dockerio.yaml create mode 100644 .gitea/workflows/ubuntu-winter.yaml create mode 100644 Dockerfile.alpine create mode 100644 Dockerfile.ubuntu create mode 100644 etc/php/fpm/php-fpm.conf create mode 100644 etc/php/fpm/pool.d/00-www.conf create mode 100644 scripts/php-fpm-init create mode 100644 scripts/php-fpm-init-alpine diff --git a/.gitea/workflows/alpine-dockerio.yaml b/.gitea/workflows/alpine-dockerio.yaml new file mode 100644 index 0000000..cbda100 --- /dev/null +++ b/.gitea/workflows/alpine-dockerio.yaml @@ -0,0 +1,125 @@ +name: Build and Push Alpine Image +on: + push: + branches: + - master + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to Docker Winter Access Git Registry + uses: docker/login-action@v3 + with: + registry: docker.io + username: aprimediet + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push 5.6 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=5 + ALPINE_VERSION=3.5 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:5.6 + aprimediet/php-fpm:5.6-alpine + - name: Build and push 7.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.9 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.2 + aprimediet/php-fpm:7.2-alpine + - name: Build and push 7.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.10 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.3 + aprimediet/php-fpm:7.3-alpine + - name: Build and push 7.4 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.13 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.4 + aprimediet/php-fpm:7.4-alpine + - name: Build and push 8.0 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=8 + ALPINE_VERSION=3.16 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.0 + aprimediet/php-fpm:8.0-alpine + - name: Build and push 8.1 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=81 + ALPINE_VERSION=3.18 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.1 + aprimediet/php-fpm:8.1-alpine + - name: Build and push 8.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=82 + ALPINE_VERSION=3.18 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.2 + aprimediet/php-fpm:8.2-alpine + - name: Build and push 8.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=83 + ALPINE_VERSION=3.19 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.3-alpine + aprimediet/php-fpm:latest-alpine diff --git a/.gitea/workflows/alpine-winter.yaml b/.gitea/workflows/alpine-winter.yaml new file mode 100644 index 0000000..51f71c2 --- /dev/null +++ b/.gitea/workflows/alpine-winter.yaml @@ -0,0 +1,117 @@ +name: Build and Push Alpine Image +on: + push: + branches: + - master + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to Docker Winter Access Git Registry + uses: docker/login-action@v3 + with: + registry: git.winteraccess.id + username: aditya.prima + password: ${{ secrets.PATOKEN }} + - name: Build and push 5.6 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=5 + ALPINE_VERSION=3.5 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:5.6 + git.winteraccess.id/${{ gitea.repository }}:5.6-alpine + - name: Build and push 7.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.9 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.2 + git.winteraccess.id/${{ gitea.repository }}:7.2-alpine + - name: Build and push 7.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.10 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.3 + git.winteraccess.id/${{ gitea.repository }}:7.3-alpine + - name: Build and push 7.4 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=7 + ALPINE_VERSION=3.13 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.4 + git.winteraccess.id/${{ gitea.repository }}:7.4-alpine + - name: Build and push 8.0 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=8 + ALPINE_VERSION=3.16 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.0 + git.winteraccess.id/${{ gitea.repository }}:8.0-alpine + - name: Build and push 8.1 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=81 + ALPINE_VERSION=3.18 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.1 + git.winteraccess.id/${{ gitea.repository }}:8.1-alpine + - name: Build and push 8.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=82 + ALPINE_VERSION=3.18 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.2 + git.winteraccess.id/${{ gitea.repository }}:8.2-alpine + - name: Build and push 8.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + PHP_VERSION=83 + ALPINE_VERSION=3.19 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.3-alpine + git.winteraccess.id/${{ gitea.repository }}:latest-alpine diff --git a/.gitea/workflows/ubuntu-dockerio.yaml b/.gitea/workflows/ubuntu-dockerio.yaml new file mode 100644 index 0000000..ac2b432 --- /dev/null +++ b/.gitea/workflows/ubuntu-dockerio.yaml @@ -0,0 +1,119 @@ +name: Build and Push Ubuntu Image +on: + push: + branches: + - master + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to Docker Winter Access Git Registry + uses: docker/login-action@v3 + with: + registry: docker.io + username: aprimediet + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push 5.6 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=5.6 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:5.6 + aprimediet/php-fpm:5.6-ubuntu + - name: Build and push 7.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.2 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.2 + aprimediet/php-fpm:7.2-ubuntu + - name: Build and push 7.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.3 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.3 + aprimediet/php-fpm:7.3-ubuntu + - name: Build and push 7.4 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.4 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:7.4 + aprimediet/php-fpm:7.4-ubuntu + - name: Build and push 8.0 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.0 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.0 + aprimediet/php-fpm:8.0-ubuntu + - name: Build and push 8.1 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.1 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.1 + aprimediet/php-fpm:8.1-ubuntu + - name: Build and push 8.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.2 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.2 + aprimediet/php-fpm:8.2-ubuntu + - name: Build and push 8.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.3 + REGISTRY_URL=aprimediet + push: true + tags: | + aprimediet/php-fpm:8.3 + aprimediet/php-fpm:8.3-ubuntu + aprimediet/php-fpm:latest-ubuntu + aprimediet/php-fpm:latest diff --git a/.gitea/workflows/ubuntu-winter.yaml b/.gitea/workflows/ubuntu-winter.yaml new file mode 100644 index 0000000..ebbf8f6 --- /dev/null +++ b/.gitea/workflows/ubuntu-winter.yaml @@ -0,0 +1,111 @@ +name: Build and Push Ubuntu Image +on: + push: + branches: + - master + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to Docker Winter Access Git Registry + uses: docker/login-action@v3 + with: + registry: git.winteraccess.id + username: aditya.prima + password: ${{ secrets.PATOKEN }} + - name: Build and push 5.6 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=5.6 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:5.6 + git.winteraccess.id/${{ gitea.repository }}:5.6-ubuntu + - name: Build and push 7.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.2 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.2 + git.winteraccess.id/${{ gitea.repository }}:7.2-ubuntu + - name: Build and push 7.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.3 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.3 + git.winteraccess.id/${{ gitea.repository }}:7.3-ubuntu + - name: Build and push 7.4 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=7.4 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.4 + git.winteraccess.id/${{ gitea.repository }}:7.4-ubuntu + - name: Build and push 8.0 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.0 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.0 + git.winteraccess.id/${{ gitea.repository }}:8.0-ubuntu + - name: Build and push 8.1 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.1 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.1 + git.winteraccess.id/${{ gitea.repository }}:8.1-ubuntu + - name: Build and push 8.2 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.2 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.2 + git.winteraccess.id/${{ gitea.repository }}:8.2-ubuntu + - name: Build and push 8.3 Images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubuntu + build-args: | + PHP_VERSION=8.3 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.3 + git.winteraccess.id/${{ gitea.repository }}:8.3-ubuntu + git.winteraccess.id/${{ gitea.repository }}:latest-ubuntu + git.winteraccess.id/${{ gitea.repository }}:latest diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..9a991ac --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,32 @@ +ARG REGISTRY_URL=git.winteraccess.id/docker +ARG PHP_VERSION=8.3 + +FROM ${REGISTRY_URL}/php:${PHP_VERSION}-alpine +LABEL maintainer=" aprimediet@gmail.com" + +ENV PHP_FPM_BIN=php-fpm${PHP_VERSION} + +WORKDIR /root + +# INSTALL PHP APP +RUN --mount=type=cache,target=/var/cache/apk \ + apk upgrade && apk add --update \ + php${PHP_VERSION}-fpm + +# REMOVE CURRENT POOL FIRST +RUN rm -rf /etc/php${PHP_VERSION}/php-fpm* + +# COPY CONFIGURATION FILES +RUN mkdir -p /etc/php/fpm +ADD ./etc /etc + +# COPY INIT SCRIPT +ADD ./scripts/php-fpm-init-alpine /usr/local/bin/php-fpm-init +RUN chmod +x /usr/local/bin/php-fpm-init + +# CLEAN APK CACHES +RUN rm -vrf /var/cache/apk/* + +ENTRYPOINT ["/usr/local/bin/php-fpm-init"] + +EXPOSE 9000 \ No newline at end of file diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 0000000..f63bf9b --- /dev/null +++ b/Dockerfile.ubuntu @@ -0,0 +1,33 @@ +ARG PHP_VERSION=8.3 +ARG REGISTRY_URL=git.winteraccess.id/docker + +FROM ${REGISTRY_URL}/php:${PHP_VERSION}-ubuntu +LABEL maintainer=" aprimediet@gmail.com" + +ENV PHP_FPM_BIN=php-fpm${PHP_VERSION} + +# Set workdir at +WORKDIR / + +# INSTALL BASE DEPENDENCIES +RUN --mount=type=cache,target=/var/cache/apt/archives \ + apt -y update && apt -y upgrade && apt -y install \ + php${PHP_VERSION}-fpm + +# REMOVE DEFAULT PHP FPM +RUN rm -rf /etc/php/${PHP_VERSION}/fpm + +# COPY CONFIGURATION FILES +ADD ./etc/php/fpm /etc/php/fpm + +# COPY INIT SCRIPT +ADD ./scripts/php-fpm-init /usr/local/bin/php-fpm-init +RUN chmod +x /usr/local/bin/php-fpm-init + +# CLEAN APT CACHE +RUN apt -y clean + +# COPY INIT SCRIPT +ENTRYPOINT ["/usr/local/bin/php-fpm-init"] + +EXPOSE 9000 \ No newline at end of file diff --git a/etc/php/fpm/php-fpm.conf b/etc/php/fpm/php-fpm.conf new file mode 100644 index 0000000..9f667f2 --- /dev/null +++ b/etc/php/fpm/php-fpm.conf @@ -0,0 +1,18 @@ +;;;;;;;;;;;;;;;;;;;;; +; FPM Configuration ; +;;;;;;;;;;;;;;;;;;;;; + +;pid = /run/php/php5.6-fpm.pid +error_log = /proc/self/fd/2 +log_level = warning +emergency_restart_threshold = 10 +emergency_restart_interval = 1m +process_control_timeout = 10s +;process.max = 128 +;process.priority = -19 +;daemonize = yes +;rlimit_files = 1024 +;rlimit_core = 0 +;events.mechanism = epoll + +include=/etc/php/fpm/pool.d/*.conf \ No newline at end of file diff --git a/etc/php/fpm/pool.d/00-www.conf b/etc/php/fpm/pool.d/00-www.conf new file mode 100644 index 0000000..7f1bef4 --- /dev/null +++ b/etc/php/fpm/pool.d/00-www.conf @@ -0,0 +1,55 @@ +[www] + +;prefix = /path/to/pools/$pool +user = root +group = root + +listen = 9000 +listen.owner = root +listen.group = root +;listen.mode = 0660 +;listen.acl_users = +;listen.acl_groups = +;listen.allowed_clients = 127.0.0.1 +; process.priority = -19 +;access.log = /proc/self/fd/2 +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" +;slowlog = log/$pool.log.slow +;request_slowlog_timeout = 0 +;request_terminate_timeout = 0 +;rlimit_files = 1024 +;rlimit_core = 0 +;chroot = +;chdir = /var/www +;catch_workers_output = yes +clear_env = no +;security.limit_extensions = .php .php3 .php4 .php5 + +; +; WORKER SETTINGS +; COPY AND ADJUST THIS FOR DIFFERENT SCENARIO +; + +pm = dynamic +pm.max_children = 10 +pm.start_servers = 5 +pm.min_spare_servers = 5 +pm.max_spare_servers = 5 +pm.process_idle_timeout = 10s; +pm.max_requests = 500 +;pm.status_path = /status +;ping.path = /ping +;ping.response = pong + +; +; PHP.INI OVERRIDE +; COPY AND ADJUST THIS FOR DIFFERENT SCENARIO +; + +php_admin_value[memory_limit] = 128M +php_admin_value[date.timezone] = Asia/Jakarta +php_value[upload_max_filesize]=256M +php_value[post_max_size]=256M +php_value[max_execution_time]=30 +php_admin_value[output_buffering]=16384 +php_value[session.save_path]="/var/lib/php/session" diff --git a/scripts/php-fpm-init b/scripts/php-fpm-init new file mode 100644 index 0000000..6842933 --- /dev/null +++ b/scripts/php-fpm-init @@ -0,0 +1,5 @@ +#!/bin/sh +echo "--------------------" +echo "Starting PHP FPM ${PHP_VERSION}" +echo "--------------------" +$PHP_FPM_BIN -F -O --allow-to-run-as-root -c /etc/php/${PHP_VERSION}/cli -y /etc/php/fpm/php-fpm.conf \ No newline at end of file diff --git a/scripts/php-fpm-init-alpine b/scripts/php-fpm-init-alpine new file mode 100644 index 0000000..5924c40 --- /dev/null +++ b/scripts/php-fpm-init-alpine @@ -0,0 +1,5 @@ +#!/bin/sh +echo "--------------------" +echo "Starting PHP FPM ${PHP_VERSION}" +echo "--------------------" +$PHP_FPM_BIN -F -O --allow-to-run-as-root -c /etc/php${PHP_VERSION} -y /etc/php/fpm/php-fpm.conf \ No newline at end of file