diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 3a16485..7b7077c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -66,6 +66,14 @@ jobs: load: true tags: kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} + - name: Build and export to Docker (Node) + uses: docker/build-push-action@v5 + if: ${{ matrix.type }} == '' + with: + context: ${{ matrix.version }}-node${{ matrix.type }} + load: true + tags: kooldev/php:${{ matrix.version }}-node${{ matrix.type }} + - name: Tests (nginx) run: | docker run kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} php -v diff --git a/8.0-node/Dockerfile b/8.0-node/Dockerfile new file mode 100644 index 0000000..9212554 --- /dev/null +++ b/8.0-node/Dockerfile @@ -0,0 +1,4 @@ +FROM kooldev/php:8.0 + +RUN apk add --update --no-cache npm yarn \ + && rm -rf /var/cache/apk/* /tmp/* diff --git a/8.1-node/Dockerfile b/8.1-node/Dockerfile new file mode 100644 index 0000000..90d7269 --- /dev/null +++ b/8.1-node/Dockerfile @@ -0,0 +1,4 @@ +FROM kooldev/php:8.1 + +RUN apk add --update --no-cache npm yarn \ + && rm -rf /var/cache/apk/* /tmp/* diff --git a/8.2-node/Dockerfile b/8.2-node/Dockerfile index 8336836..85f542d 100644 --- a/8.2-node/Dockerfile +++ b/8.2-node/Dockerfile @@ -1,83 +1,4 @@ -FROM php:8.2-fpm-alpine +FROM kooldev/php:8.2 -ENV ASUSER= \ - UID= \ - COMPOSER_ALLOW_SUPERUSER=1 \ - COMPOSER_MEMORY_LIMIT=-1 \ - ENABLE_XDEBUG=false \ - PHP_DATE_TIMEZONE=UTC \ - PHP_MEMORY_LIMIT=256M \ - PHP_MAX_INPUT_VARS=1000 \ - PHP_UPLOAD_MAX_FILESIZE=25M \ - PHP_POST_MAX_SIZE=25M \ - PHP_MAX_EXECUTION_TIME=30 \ - PHP_FPM_LISTEN=9000 \ - PHP_FPM_MAX_CHILDREN=10 \ - PHP_FPM_REQUEST_TERMINATE_TIMEOUT=60 \ - ENTRYPOINT=entrypoint.php.sh - -WORKDIR /app - -RUN adduser -D -u 1337 kool \ - && addgroup kool www-data \ - # dockerize - && curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \ - && mv dockerize /usr/local/bin/dockerize \ - # deps - && apk --no-cache add su-exec bash sed git openssh-client icu shadow procps \ - freetype libpng libjpeg-turbo libzip-dev ghostscript imagemagick \ - jpegoptim optipng pngquant gifsicle libldap \ - libpq less \ - # build-deps - && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ - freetype-dev libpng-dev libjpeg-turbo-dev \ - icu-dev libedit-dev libxml2-dev \ - imagemagick-dev openldap-dev oniguruma-dev \ - postgresql-dev \ - linux-headers \ - # php-ext - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \ - && docker-php-ext-install -j$(nproc) \ - bcmath \ - calendar \ - exif \ - gd \ - intl \ - ldap \ - mbstring \ - pcntl \ - pdo \ - pdo_mysql \ - pdo_pgsql \ - soap \ - xml \ - zip \ - sockets \ - mysqli \ - && pecl install imagick redis \ - && pecl install xdebug \ - && pecl install pcov && docker-php-ext-enable pcov \ - && docker-php-ext-enable imagick \ - && docker-php-ext-enable redis \ - && cp "/usr/local/etc/php/php.ini-development" "/usr/local/etc/php/php.ini" \ - # composer - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ - && curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer1 \ - # symlink composer2 for BC - && ln -s /usr/local/bin/composer /usr/local/bin/composer2 \ - # cleanup - && apk del .build-deps \ +RUN apk add --update --no-cache npm yarn \ && rm -rf /var/cache/apk/* /tmp/* - -RUN apk add --update --no-cache npm - -COPY kool.ini /kool/kool.tmpl -COPY zz-docker.conf /kool/zz-docker.tmpl -COPY entrypoint /kool/entrypoint -RUN chmod +x /kool/entrypoint - -EXPOSE 9000 - -ENTRYPOINT [ "/kool/entrypoint" ] -CMD [ "php-fpm" ] diff --git a/8.2-node/entrypoint b/8.2-node/entrypoint deleted file mode 100644 index 050f40a..0000000 --- a/8.2-node/entrypoint +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -set -e - -if [ "$ENABLE_XDEBUG" == "true" ]; then - docker-php-ext-enable xdebug >> /dev/null 2>&1 - - if [ $? != "0" ]; then - echo "[ERROR] An error happened enabling xdebug" - - exit 1 - fi -fi - -# Run as current user -CURRENT_USER=${ASUSER:-${UID:-0}} - -if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then - usermod -u $CURRENT_USER kool -fi - -dockerize -template /kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini -template /kool/zz-docker.tmpl:/usr/local/etc/php-fpm.d/zz-docker.conf - - -# Run entrypoint if provided -if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then - bash $ENTRYPOINT -fi - -if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] ; then - exec "$@" -else - exec su-exec kool "$@" -fi diff --git a/8.2-node/kool.ini b/8.2-node/kool.ini deleted file mode 100644 index c671911..0000000 --- a/8.2-node/kool.ini +++ /dev/null @@ -1,29 +0,0 @@ -[PHP] - -; Maximum amount of memory a script may consume -; http://php.net/memory-limit -memory_limit = {{ .Env.PHP_MEMORY_LIMIT }} - -; Fix maximum variables per input -max_input_vars = {{ .Env.PHP_MAX_INPUT_VARS }} - -; Maximum allowed size for uploaded files. -; http://php.net/upload-max-filesize -upload_max_filesize = {{ .Env.PHP_UPLOAD_MAX_FILESIZE }} - -; Maximum size of POST data that PHP will accept. -; Its value may be 0 to disable the limit. It is ignored if POST data reading -; is disabled through enable_post_data_reading. -; http://php.net/post-max-size -post_max_size = {{ .Env.PHP_POST_MAX_SIZE }} - -; Maximum execution time of each script, in seconds -; http://php.net/max-execution-time -; Note: This directive is hardcoded to 0 for the CLI SAPI -max_execution_time = {{ .Env.PHP_MAX_EXECUTION_TIME }} - -; Default timezone used by all date/time functions. -; https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone -date.timezone = {{ .Env.PHP_DATE_TIMEZONE }} - - diff --git a/8.2-node/zz-docker.conf b/8.2-node/zz-docker.conf deleted file mode 100644 index c6988a1..0000000 --- a/8.2-node/zz-docker.conf +++ /dev/null @@ -1,48 +0,0 @@ -[global] -daemonize = no - -[www] -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = kool -group = kool - -; The address on which to accept FastCGI requests. -; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on -; a specific port; -; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses -; (IPv6 and IPv4-mapped) on a specific port; -; '/path/to/unix/socket' - to listen on a unix socket. -; Note: This value is mandatory. -listen = {{ .Env.PHP_FPM_LISTEN }} - -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. The owner -; and group can be specified either by name or by their numeric IDs. -; Default Values: user and group are set as the running user -; mode is set to 0660 -listen.owner = kool -listen.group = kool - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = {{ .Env.PHP_FPM_MAX_CHILDREN }} - -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -request_terminate_timeout = {{ .Env.PHP_FPM_REQUEST_TERMINATE_TIMEOUT }} diff --git a/fwd-template.json b/fwd-template.json index d096c25..e4e34df 100644 --- a/fwd-template.json +++ b/fwd-template.json @@ -109,6 +109,19 @@ } ] }, + { + "name": "8.0-node", + "data": { + "from": "kooldev/php:8.0", + "version": "8.0" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile-node" + } + ] + }, { "name": "8.1", "data": { @@ -218,37 +231,23 @@ ] }, { - "name": "8.2", + "name": "8.1-node", "data": { - "from": "php:8.2-fpm-alpine", - "prod": false, - "nginx": false, - "version": "8.2" + "from": "kooldev/php:8.1", + "version": "8.1" }, "files": [ { "name": "Dockerfile", - "path": "template/Dockerfile" - }, - { - "name": "entrypoint", - "path": "template/entrypoint" - }, - { - "name": "kool.ini", - "path": "template/kool-ini" - }, - { - "name": "zz-docker.conf", - "path": "template/zz-docker-conf" + "path": "template/Dockerfile-node" } ] }, { - "name": "8.2-prod", + "name": "8.2", "data": { "from": "php:8.2-fpm-alpine", - "prod": true, + "prod": false, "nginx": false, "version": "8.2" }, @@ -272,11 +271,10 @@ ] }, { - "name": "8.2-node", + "name": "8.2-prod", "data": { "from": "php:8.2-fpm-alpine", - "with_node": true, - "prod": false, + "prod": true, "nginx": false, "version": "8.2" }, @@ -352,6 +350,19 @@ "path": "template/supervisor-conf" } ] + }, + { + "name": "8.2-node", + "data": { + "from": "kooldev/php:8.2", + "version": "8.2" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile-node" + } + ] } ] } diff --git a/kool.yml b/kool.yml index c297cd5..04e57d6 100644 --- a/kool.yml +++ b/kool.yml @@ -5,17 +5,19 @@ scripts: - docker build --pull -t kooldev/php:8.0-prod 8.0-prod - docker build -t kooldev/php:8.0-nginx 8.0-nginx - docker build -t kooldev/php:8.0-nginx-prod 8.0-nginx-prod + - docker build -t kooldev/php:8.0-node 8.0-node build-8.1: - - docker build --pull -t kooldev/php:8.1 8.1 - - docker build --pull -t kooldev/php:8.1-prod 8.1-prod + - docker build -t kooldev/php:8.1 8.1 + - docker build -t kooldev/php:8.1-prod 8.1-prod - docker build -t kooldev/php:8.1-nginx 8.1-nginx - docker build -t kooldev/php:8.1-nginx-prod 8.1-nginx-prod + - docker build -t kooldev/php:8.1-node 8.1-node build-8.2: - - docker build --pull -t kooldev/php:8.2 8.2 - - docker build --pull -t kooldev/php:8.2-prod 8.2-prod - - docker build --pull -t kooldev/php:8.2-node 8.2-node + - docker build -t kooldev/php:8.2 8.2 + - docker build -t kooldev/php:8.2-prod 8.2-prod - docker build -t kooldev/php:8.2-nginx 8.2-nginx - docker build -t kooldev/php:8.2-nginx-prod 8.2-nginx-prod + - docker build -t kooldev/php:8.2-node 8.2-node build: # parse templates - kool run template diff --git a/template/Dockerfile-node.blade.php b/template/Dockerfile-node.blade.php new file mode 100644 index 0000000..2017828 --- /dev/null +++ b/template/Dockerfile-node.blade.php @@ -0,0 +1,4 @@ +FROM {{ $from }} + +RUN apk add --update --no-cache npm yarn \ + && rm -rf /var/cache/apk/* /tmp/* diff --git a/template/Dockerfile.blade.php b/template/Dockerfile.blade.php index f2d360c..80cd872 100644 --- a/template/Dockerfile.blade.php +++ b/template/Dockerfile.blade.php @@ -84,10 +84,6 @@ && apk del .build-deps \ && rm -rf /var/cache/apk/* /tmp/* -@if ($with_node ?? false) -RUN apk add --update --no-cache npm - -@endif COPY kool.ini /kool/kool.tmpl COPY zz-docker.conf /kool/zz-docker.tmpl COPY entrypoint /kool/entrypoint