From f9879a0ffb42bdc91e52e541bc6d067cc00669da Mon Sep 17 00:00:00 2001 From: Aditya Prima Date: Thu, 19 Sep 2024 15:42:36 +0700 Subject: [PATCH] Added alpine linux php-apache base image --- .gitea/workflows/alpine-dockerio.yaml | 118 +++++++++++++++++++++++++- .gitea/workflows/alpine-winter.yaml | 110 +++++++++++++++++++++++- Dockerfile.apache-alpine | 48 +++++++++++ scripts/apache-entrypoint-alpine | 5 ++ 4 files changed, 277 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.apache-alpine create mode 100644 scripts/apache-entrypoint-alpine diff --git a/.gitea/workflows/alpine-dockerio.yaml b/.gitea/workflows/alpine-dockerio.yaml index f69c1b3..882d7db 100644 --- a/.gitea/workflows/alpine-dockerio.yaml +++ b/.gitea/workflows/alpine-dockerio.yaml @@ -1,4 +1,4 @@ -name: Build and Push Alpine PHP 8.3 Image +name: Build and Push Alpine PHP Image on: push: branches: @@ -116,4 +116,118 @@ jobs: tags: | aprimediet/php:8-alpine aprimediet/php:8.3-alpine - aprimediet/php:latest-alpine \ No newline at end of file + aprimediet/php:latest-alpine + build-apache: + name: Build and push apache image + runs-on: ubuntu-latest + needs: + - build + 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 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.5 + PHP_VERSION=5 + push: true + tags: | + aprimediet/php:5.6-apache-alpine + - name: Build and push 7.2 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.9 + PHP_VERSION=7 + push: true + tags: | + aprimediet/php:7.2-apache-alpine + - name: Build and push 7.3 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.10 + PHP_VERSION=7 + push: true + tags: | + aprimediet/php:7.3-apache-alpine + - name: Build and push 7.4 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.13 + PHP_VERSION=7 + push: true + tags: | + aprimediet/php:7.4-apache-alpine + - name: Build and push 8.0 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.16 + PHP_VERSION=8 + push: true + tags: | + aprimediet/php:8.0-apache-alpine + - name: Build and push 8.1 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.18 + PHP_VERSION=81 + push: true + tags: | + aprimediet/php:8.1-apache-alpine + - name: Build and push 8.2 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.18 + PHP_VERSION=82 + push: true + tags: | + aprimediet/php:8.2-apache-alpine + - name: Build and push 8.3 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + REGISTRY_URL=docker.io/aprimediet + ALPINE_VERSION=3.19 + PHP_VERSION=83 + push: true + tags: | + aprimediet/php:8-apache-alpine + aprimediet/php:8.3-apache-alpine + aprimediet/php:latest-apache-alpine \ No newline at end of file diff --git a/.gitea/workflows/alpine-winter.yaml b/.gitea/workflows/alpine-winter.yaml index 09f7064..60dd137 100644 --- a/.gitea/workflows/alpine-winter.yaml +++ b/.gitea/workflows/alpine-winter.yaml @@ -1,4 +1,4 @@ -name: Build and Push Alpine PHP 8.3 Image +name: Build and Push Alpine PHP Image on: push: branches: @@ -107,4 +107,110 @@ jobs: push: true tags: | git.winteraccess.id/${{ gitea.repository }}:8.3-alpine - git.winteraccess.id/${{ gitea.repository }}:latest-alpine \ No newline at end of file + git.winteraccess.id/${{ gitea.repository }}:latest-alpine + build-apache: + name: Build and push apache image + runs-on: ubuntu-latest + needs: + - build + 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 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.5 + PHP_VERSION=5 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:5.6-apache-alpine + - name: Build and push 7.2 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.9 + PHP_VERSION=7 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.2-apache-alpine + - name: Build and push 7.3 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.10 + PHP_VERSION=7 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.3-apache-alpine + - name: Build and push 7.4 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.13 + PHP_VERSION=7 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:7.4-apache-alpine + - name: Build and push 8.0 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.16 + PHP_VERSION=8 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.0-apache-alpine + - name: Build and push 8.1 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.18 + PHP_VERSION=81 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.1-apache-alpine + - name: Build and push 8.2 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.18 + PHP_VERSION=82 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8.2-apache-alpine + - name: Build and push 8.3 with Apache2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.apache-alpine + build-args: | + ALPINE_VERSION=3.19 + PHP_VERSION=83 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:8-apache-alpine + git.winteraccess.id/${{ gitea.repository }}:8.3-apache-alpine + git.winteraccess.id/${{ gitea.repository }}:latest-apache-alpine \ No newline at end of file diff --git a/Dockerfile.apache-alpine b/Dockerfile.apache-alpine new file mode 100644 index 0000000..b5ec159 --- /dev/null +++ b/Dockerfile.apache-alpine @@ -0,0 +1,48 @@ +ARG REGISTRY_URL=git.winteraccess.id/docker +ARG PHP_VERSION=8.3 + +FROM ${REGISTRY_URL}/php:${PHP_VERSION}-alpine +LABEL maintainer " aprimediet@gmail.com" + +# DEFINE ENV +ENV SERVER_ROOT /app +ENV SERVER_ADMIN you@example.com +ENV APP_DIR ${SERVER_ROOT}/htdocs +ENV LOG_LEVEL info +ENV PHP_MEMORY_LIMIT 256M + +# SET WORKDIR +WORKDIR /tmp + +# INSTALL APACHE2 +RUN --mount=type=cache,target=/var/cache/apk \ + apk upgrade && apk add --update \ + apache2 php${PHP_VERSION}-apache2 + +# CREATE SYMLINKS TO /app +RUN mkdir -p /app/htdocs && \ + ln -s /var/log/apache2 /app/logs && \ + ln -s /usr/lib/apache2 /app/modules && \ + ln -s /run/apache2 /app/run + +# CONFIGURE HTTPD +RUN sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd.conf && \ + sed -i "s|ServerAdmin you@example.com| ServerAdmin ${SERVER_ADMIN}|" /etc/apache2/httpd.conf && \ + sed -i "s|DocumentRoot \"/var/www/localhost/htdocs\"|DocumentRoot \"${APP_DIR}\"|" /etc/apache2/httpd.conf && \ + sed -i "s|Directory \"/var/www/localhost/htdocs\"|Directory \"${APP_DIR}\"|" /etc/apache2/httpd.conf && \ + sed -i "s|AllowOverride None|AllowOverride All|" /etc/apache2/httpd.conf && \ + sed -i "s|ErrorLog .*|ErrorLog /dev/stderr \nTransferLog /dev/stdout|" /etc/apache2/httpd.conf && \ + sed -i "s|CustomLog .* combined|CustomLog /dev/stdout combined|" /etc/apache2/httpd.conf && \ + sed -i "s|LogLevel .*|LogLevel ${LOG_LEVEL}|" /etc/apache2/httpd.conf + +# ADD INITIALIZATION SCRIPT +ADD ./scripts/apache-entrypoint-alpine /usr/local/bin/entrypoint +RUN chmod +x /usr/local/bin/entrypoint && \ + cp -vR /var/www/localhost/htdocs/* ${APP_DIR}/ && \ + chown -R apache:apache ${APP_DIR} + +WORKDIR ${APP_DIR} + +EXPOSE 80 + +ENTRYPOINT ["/usr/local/bin/entrypoint"] diff --git a/scripts/apache-entrypoint-alpine b/scripts/apache-entrypoint-alpine new file mode 100644 index 0000000..4e5a26a --- /dev/null +++ b/scripts/apache-entrypoint-alpine @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "RUNNING APACHE2" + +httpd -D FOREGROUND \ No newline at end of file