Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update the php version to 8.3 #14

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Push Docker Image

on:
push:
branches:
- "7.4"
- "7.4-s6"
- "8.2"
- "8.2-s6"
- "8.3-s6"

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
timeout-minutes: 5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
timeout-minutes: 5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
timeout-minutes: 5
- name: Create Tag
id: tag
run: echo "tag=${{ github.ref_name }}-$(git rev-parse --short HEAD)-$(date +%s)" >> $GITHUB_OUTPUT
timeout-minutes: 5
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: improwised/php-base:${{ steps.tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
timeout-minutes: 5
75 changes: 44 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM alpine:3.8
MAINTAINER Rakshit Menpara <rakshit@improwised.com>
FROM alpine:edge

ENV composer_hash 48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5
ENV DOCKERIZE_VERSION v0.6.1
# set version for s6 overlay
ARG S6_OVERLAY_VERSION="3.1.5.0"
ARG S6_OVERLAY_ARCH="x86_64"
ENV UID=100 \
GID=101 \
FPM_LOG_LEVEL=warning

RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
Expand All @@ -12,64 +17,72 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
# Install OS Dependencies
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
gmp-dev tar \
&& apk add --no-cache --virtual .run-deps \
autoconf automake build-base python3 gmp-dev \
curl \
nodejs nodejs-npm \
tar \
&& apk add --no-cache --virtual .run-deps \
nodejs npm libavif \
&& apk --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/community add \
# PHP and extensions
php7 php7-apcu php7-bcmath php7-dom php7-ctype php7-curl php7-exif php7-fileinfo \
php7-fpm php7-gd php7-gmp php7-iconv php7-intl php7-json php7-mbstring php7-mcrypt \
php7-mysqlnd php7-mysqli php7-opcache php7-openssl php7-pcntl php7-pdo php7-pdo_mysql \
php7-phar php7-posix php7-session php7-simplexml php7-sockets php7-sqlite3 php7-tidy \
php7-tokenizer php7-xml php7-xmlwriter php7-zip php7-zlib php7-redis php7-soap \
php7-pdo_pgsql php7-xmlreader \
php83 php83-bcmath php83-ctype php83-curl php83-dom php83-exif php83-fileinfo \
php83-fpm php83-gd php83-gmp php83-iconv php83-intl php83-mbstring \
php83-mysqlnd php83-mysqli php83-opcache php83-openssl php83-pcntl php83-pecl-apcu php83-pdo php83-pdo_mysql \
php83-phar php83-posix php83-session php83-simplexml php83-sockets php83-sqlite3 php83-tidy \
php83-tokenizer php83-xml php83-xmlreader php83-xmlwriter php83-zip php83-pecl-xdebug php83-pecl-redis php83-soap php83-sodium php83-pdo_sqlite php83-pdo_pgsql php83-pgsql \
# Other dependencies
mariadb-client sudo \
mariadb-client sudo shadow \
# Miscellaneous packages
bash ca-certificates dialog git libjpeg libpng-dev openssh-client supervisor vim wget \
bash ca-certificates dialog git libjpeg libpng-dev openssh-client vim wget shadow \
Annavar-satish marked this conversation as resolved.
Show resolved Hide resolved
# Nginx
nginx \
# Create directories
&& mkdir -p /etc/nginx \
&& mkdir -p /run/nginx \
&& mkdir -p /etc/nginx/sites-available \
&& mkdir -p /etc/nginx/sites-enabled \
&& mkdir -p /var/log/supervisor \
&& rm -Rf /var/www/* \
&& rm -Rf /etc/nginx/nginx.conf \
# Composer
&& php7 -r "copy('https://raw.githubusercontent.com/composer/getcomposer.org/cb19f2aa3aeaa2006c0cd69a7ef011eb31463067/web/installer', 'composer-setup.php');" \
&& php7 -r "if (hash_file('SHA384', 'composer-setup.php') === '${composer_hash}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php7 composer-setup.php --install-dir=/usr/bin --filename=composer \
&& php7 -r "unlink('composer-setup.php');" \
&& wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig \
&& php83 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php83 -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php83 composer-setup.php --install-dir=/usr/bin --filename=composer \
&& php83 -r "unlink('composer-setup.php'); unlink('installer.sig');" \
# Cleanup
&& apk del .build-deps

################## INSTALLATION ENDS ##################

# add s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz

# add s6 optional symlinks
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz

################## CONFIGURATION STARTS ##################

ADD rootfs /

RUN ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf && \
ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini && \
ln -s /etc/php83/php.ini /etc/php83/conf.d/php.ini && \
rm -rf /usr/bin/php && \
ln -s /usr/bin/php83 /usr/bin/php && \
chown -R nginx:nginx /var/www && \
chmod 755 /etc/s6-overlay/s6-rc.d/*/run && \
chmod 755 /etc/s6-overlay/s6-rc.d/*/up && \
mkdir -p /var/www/storage/logs/ && \
touch /var/www/storage/logs/laravel.log /var/log/nginx/error.log /var/log/php7/error.log
touch /var/www/storage/logs/laravel.log /var/log/nginx/error.log /var/log/php83/error.log

################## CONFIGURATION ENDS ##################

EXPOSE 443 80

WORKDIR /var/www

ENTRYPOINT ["dockerize", \
"-template", "/etc/php7/php.ini:/etc/php7/php.ini", \
"-template", "/etc/php7/php-fpm.conf:/etc/php7/php-fpm.conf", \
"-template", "/etc/php7/php-fpm.d:/etc/php7/php-fpm.d", \
"-stdout", "/var/www/storage/logs/laravel.log", \
"-stdout", "/var/log/nginx/error.log", \
"-stdout", "/var/log/php7/error.log", \
"-poll"]

CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
ENTRYPOINT ["/init"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Base container image for modern PHP applications built on top of Alpine Linux. T
* Create a `Dockerfile` in root of your PHP project.

```dockerfile
FROM improwised/php-base:latest
FROM improwised/php-base:<tag>

# Copy Composer
COPY ./composer.* /var/www/
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
; into a local file.
; Note: the default prefix is /var
; Default Value: log/php7/error.log
error_log = /var/log/php7/error.log
error_log = /var/log/php83/error.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
Expand Down Expand Up @@ -122,6 +122,6 @@ daemonize = no
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /usr otherwise
include=/etc/php7/php-fpm.d/*.conf
include=/etc/php83/php-fpm.d/*.conf

php_flag[display_errors] = {{ default .Env.PHP_DISPLAY_ERRORS "off" }}
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pm.max_requests = 200
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/php7/$pool.slow.log
slowlog = /var/log/php83/$pool.slow.log

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
Expand Down Expand Up @@ -408,6 +408,6 @@ clear_env = no
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
php_flag[display_errors] = On
php_admin_value[error_log] = /var/log/php7/$pool.error.log
php_admin_value[error_log] = /var/log/php83/$pool.error.log
php_admin_flag[log_errors] = On
;php_admin_value[memory_limit] = 32M
18 changes: 9 additions & 9 deletions rootfs/etc/php7/php.ini → rootfs/etc/php83/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1779,23 +1779,23 @@ ldap.max_links = -1

[opcache]
; Determines if Zend OPCache is enabled
;opcache.enable=1
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
opcache.enable_cli=1

; The OPcache shared memory storage size.
;opcache.memory_consumption=128
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
;opcache.interned_strings_buffer=8
opcache.interned_strings_buffer=16

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
;opcache.max_accelerated_files=10000
opcache.max_accelerated_files=10000

; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5
opcache.max_wasted_percentage=10

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
Expand All @@ -1805,12 +1805,12 @@ ldap.max_links = -1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
;opcache.validate_timestamps=1
opcache.validate_timestamps=0

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
;opcache.revalidate_freq=2
opcache.revalidate_freq=0

; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0
Expand All @@ -1821,7 +1821,7 @@ ldap.max_links = -1

; If enabled, a fast shutdown sequence is used for the accelerated code
; Depending on the used Memory Manager this may cause some incompatibilities.
;opcache.fast_shutdown=0
opcache.fast_shutdown=1

; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# copy default config files if they don't exist
if [[ ! -f /etc/nginx/sites-enabled/default.conf ]]; then
cp /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf
fi
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-nginx/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-nginx/run
Empty file.
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-php83-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# add environment variable into files
dockerize -template /etc/php83/php.ini:/etc/php83/php.ini -template /etc/php83/php-fpm.conf:/etc/php83/php-fpm.conf -template /etc/php83/php-fpm.d:/etc/php83/php-fpm.d
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-php83-fpm/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-php83-fpm/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-php83-fpm/run
Empty file.
8 changes: 8 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-usermod/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

UID=${UID:-911}
GID=${GID:-911}

echo "User Id $UID, Group id $GID"
usermod -u "$UID" nginx && groupmod -g "$GID" nginx
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-usermod/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/init-usermod/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-usermod/run
Empty file.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash

/usr/sbin/nginx -g "daemon off;"
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-php83-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash

/usr/sbin/php-fpm83 --nodaemonize --fpm-config /etc/php83/php-fpm.conf
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-php83-fpm/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-stdout/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash

dockerize -stdout /var/www/storage/logs/laravel.log -stdout /var/log/nginx/error.log -stdout /var/log/php83/error.log -poll
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-stdout/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
46 changes: 0 additions & 46 deletions rootfs/etc/supervisord.conf

This file was deleted.

4 changes: 4 additions & 0 deletions rootfs/etc/usermod/setuid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

echo "User Id $UID, Group id $GID"
usermod -u "$UID" nginx && groupmod -g "$GID" nginx