diff --git a/.gitea/workflows/php5.yaml b/.gitea/workflows/php5.yaml index 66f109d..4701f1a 100644 --- a/.gitea/workflows/php5.yaml +++ b/.gitea/workflows/php5.yaml @@ -13,6 +13,7 @@ jobs: image: ghcr.io/catthehacker/ubuntu:act-latest strategy: matrix: + server: ["blank", "apache"] flavors: ["cli", "full", "debug"] version: - os: "alpine" @@ -32,7 +33,8 @@ jobs: # uses: docker/setup-qemu-action@v3 - name: Setup Docker buildx uses: docker/setup-buildx-action@v3 - - name: Build and push php on alpine base + - if: ${{ matrix.server == 'blank' }} + name: Build and push php5 uses: docker/build-push-action@v5 with: push: true @@ -45,6 +47,21 @@ jobs: PHP_VER_SHORT=${{ matrix.version.php_ver_short }} tags: | quay.io/sindigilive/php:${{ matrix.version.php_version }}-${{ matrix.flavors }}-${{ matrix.version.os }} + - if: ${{ matrix.server == 'apache' && (matrix.flavors == 'full' || matrix.flavors == 'debug') }} + name: Build and push php5 with apache2 + uses: docker/build-push-action@v5 + with: + push: true + context: . + file: 5/Dockerfile.${{ matrix.version.server }}-${{ matrix.version.os }} + build-args: | + OS_VERSION=${{ matrix.version.os_version }} + FLAVOR=${{ matrix.flavors }} + PHP_VERSION=${{ matrix.version.php_version }} + PHP_VER_SHORT=${{ matrix.version.php_ver_short }} + WITH_APACHE=true + tags: | + quay.io/sindigilive/php:${{ matrix.version.php_version }}-${{ matrix.server }}-${{ matrix.flavors }}-${{ matrix.version.os }} # build-latest: # name: Build latest nginx alpine based container images # runs-on: ubuntu-latest diff --git a/5/Dockerfile.alpine b/5/Dockerfile.alpine index b59da68..b55a03d 100644 --- a/5/Dockerfile.alpine +++ b/5/Dockerfile.alpine @@ -5,10 +5,12 @@ FROM quay.io/sindigilive/alpine:${OS_VERSION} AS builder LABEL maintainer=" map@sindigilive.com" ARG FLAVOR=cli +ARG WITH_APACHE=false ARG PHP_VERSION=5.6 ARG PHP_VER_SHORT=5 ENV FLAVOR=${FLAVOR} +ENV WITH_APACHE=${WITH_APACHE} ENV PHP_VERSION=${PHP_VERSION} ENV PHP_VER_SHORT=${PHP_VER_SHORT} diff --git a/5/Dockerfile.apache-alpine b/5/Dockerfile.apache-alpine new file mode 100644 index 0000000..5ff8f9a --- /dev/null +++ b/5/Dockerfile.apache-alpine @@ -0,0 +1,68 @@ +# PHP 5.6 == 3.5 +ARG OS_VERSION=3.5 + +FROM quay.io/sindigilive/alpine:${OS_VERSION} AS builder +LABEL maintainer=" map@sindigilive.com" + +ARG FLAVOR=cli +ARG WITH_APACHE=false +ARG PHP_VERSION=5.6 +ARG PHP_VER_SHORT=5 + +ENV FLAVOR=${FLAVOR} +ENV WITH_APACHE=${WITH_APACHE} +ENV PHP_VERSION=${PHP_VERSION} +ENV PHP_VER_SHORT=${PHP_VER_SHORT} + +WORKDIR /root + +ADD 5/scripts/alpine-setup.sh /tmp/setup.sh +ADD scripts/entrypoint.sh /usr/local/bin + +# Create directory, and install required php app +RUN /bin/mkdir -p /app ; \ + /sbin/apk add --update --no-cache \ + php${PHP_VER_SHORT} php${PHP_VER_SHORT}-common \ + php${PHP_VER_SHORT}-cli ; \ + /bin/chmod +x /tmp/setup.sh /usr/local/bin/entrypoint.sh ; \ + /bin/sh /tmp/setup.sh; \ + /bin/rm -f /tmp/*.sh; + +ADD htdocs /app/htdocs + +# Create symlinks to /usr/bin/php in case it doesn't exists +RUN ln -ns /usr/bin/php${PHP_VER_SHORT} /usr/bin/php ; exit 0 + +# CLEAN APK CACHES +RUN sed -i "s|#version#|${PHP_VERSION}|" /app/htdocs/index.html ; \ + sed -i "s|#os#|alpine|" /app/htdocs/index.html ; \ + sed -i "s|#flavor#|${FLAVOR}|" /app/htdocs/index.html ; \ + chown apache:apache /app/htdocs; \ + rm -vrf /var/cache/apk/* + +FROM scratch + +ARG PHP_VERSION=5.6 +ARG PHP_VER_SHORT=5 + +ENV PHP_VERSION=${PHP_VERSION} +ENV PHP_VER_SHORT=${PHP_VER_SHORT} + +LABEL maintainer="Muhamad Aditya Prima " +LABEL name="php" +LABEL version="${PHP_VERSION}" +LABEL distribution-scope="public" + +#labels for container catalog +LABEL summary="PHP ${PHP_VERSION} on alpine based container image" +LABEL description="Provide php on alpine based container base image" +LABEL io.k8s.description="Very small alpine linux container image" +LABEL io.k8s.display-name="PHP ${PHP_VERSION}" + +COPY --from=builder / / + +WORKDIR /app + +STOPSIGNAL SIGQUIT + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/5/scripts/alpine-setup.sh b/5/scripts/alpine-setup.sh index 4828444..531bcca 100644 --- a/5/scripts/alpine-setup.sh +++ b/5/scripts/alpine-setup.sh @@ -11,19 +11,46 @@ phpmailer,posix,pspell,shmop, snmp,soap,sockets,sysvmsg,sysvsem, sysvshm,wddx,xcache,xml,xmlreader, xmlrpc,xsl,zip,zlib" - PHP_DEPS="" +# apache2 configurations +SERVER_ROOT="/app" +APP_ROOT="$SERVER_ROOT/htdocs" +LOG_LEVEL="info" -echo $FLAVOR +# Setup php flavor if [[ "$FLAVOR" == "debug" ]]; then + LOG_LEVEL="debug" /sbin/apk add --update --no-cache php$PHP_VER_SHORT-dbg; fi if [ "$FLAVOR" == "full" ] || [ "$FLAVOR" == "debug" ]; then - for i in $(echo $PHP_LIST | tr "," "\n"); do PHP_DEPS="${PHP_DEPS} php$PHP_VER_SHORT-$i "; done -/sbin/apk add --update --no-cache $PHP_DEPS; \ No newline at end of file +/sbin/apk add --update --no-cache $PHP_DEPS; +fi + +# Only setup apache with full flavor parameters +if [ "$WITH_APACHE" == "true" ]; then + if [ "$FLAVOR" == "full" ] || [ "$FLAVOR" == "debug" ]; then + /usr/sbin/addgroup -g 10001 apache ; + /usr/sbin/adduser -D -u 10001 -G apache -s /bin/sh -h $APP_ROOT apache ; + /sbin/apk add --update --no-cache apache2 php$PHP_VER_SHORT-apache2; + + sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd.conf ; + sed -i "s|ServerAdmin you@example.com| ServerAdmin map@sindigilive.com|" /etc/apache2/httpd.conf ; + sed -i "s|DocumentRoot \"/var/www/localhost/htdocs\"|DocumentRoot \"${APP_ROOT}\"|" /etc/apache2/httpd.conf ; + sed -i "s|Directory \"/var/www/localhost/htdocs\"|Directory \"${APP_ROOT}\"|" /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 ; + sed -i "s|#LoadModule rewrite_module|LoadModule rewrite_module|" /etc/apache2/httpd.conf ; + sed -i "s|#LoadModule deflate_module|LoadModule deflate_module|" /etc/apache2/httpd.conf ; + sed -i "s|#LoadModule expires_module|LoadModule expires_module|" /etc/apache2/httpd.conf ; + sed -i "s|Require host .example.com|#Require host .example.com|" /etc/apache2/conf.d/info.conf ; + sed -i "s|Require ip 127|Require all granted|" /etc/apache2/conf.d/info.conf ; + fi +fi \ No newline at end of file diff --git a/app/index.html b/htdocs/index.html similarity index 74% rename from app/index.html rename to htdocs/index.html index f4020d2..93e53fd 100644 --- a/app/index.html +++ b/htdocs/index.html @@ -12,15 +12,15 @@

Welcome to httpd!

-

The aprimediet/php:version-apache variant.

+

The sindigilive/php:#version#-apache-#flavor#-#os# variant.

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to httpd.apache.org.

-

For online documentation specific to the aprimediet/php:version-apache,
-please refer to aprimediet/php.

+

For online documentation specific to the sindigilive/php:#version#-apache-#flavor#-#os# variant,
+please refer to sindigilive/php.

Thank you for using httpd.

diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 12a1444..72bc352 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,7 +1,9 @@ #!/bin/sh -echo "##########################" -echo "# Apache2 is starting up #" -echo "##########################" +/bin/echo "### PHP version :$PHP_VERSION ###"; +/bin/echo "### Maintainer: map@sindigilive.com ###"; +/bin/echo ""; +/bin/echo "### Starting HTTPD Server ###"; +/bin/echo ""; httpd -D FOREGROUND \ No newline at end of file