diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 0ad822b924..47ad3b2af5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -38,7 +38,7 @@ jobs: run: docker-compose up -d - name: Initialise Litus - run: docker-compose run --rm php-cli init + run: docker-compose run --rm litus init - name: Test response run: curl -fsSL -I --retry 5 --retry-delay 0 --retry-max-time 30 http://localhost:8080 diff --git a/Dockerfile b/Dockerfile index ff6a714e41..57047a9d2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ -# dependencies FROM caddy:2.6.2 AS caddy -# development FROM composer:2.4.4 AS composer ARG APPLICATION_ENV=development @@ -47,41 +45,23 @@ RUN \ --optimize; \ fi -FROM php:8.1.9-cli-alpine AS php-cli +FROM dunglas/frankenphp:latest-alpine AS frankenphp ARG APPLICATION_ENV=development ENV APPLICATION_ENV=${APPLICATION_ENV} ARG COMMIT_SHA ENV COMMIT_SHA=${COMMIT_SHA} -RUN apk add --no-cache \ - icu \ - imagemagick \ - libgomp \ - libpq \ - libxml2 \ - libzip && \ - apk add --no-cache --virtual .phpize-deps \ - $PHPIZE_DEPS \ - icu-dev \ - imagemagick-dev \ - libxml2-dev \ - libzip-dev \ - postgresql-dev && \ - docker-php-ext-install "-j$(nproc)" \ - intl \ - opcache \ - pdo_pgsql \ - pgsql \ - soap \ - zip && \ - pecl install imagick && \ - docker-php-ext-enable imagick && \ - pecl install mailparse && \ - docker-php-ext-enable mailparse && \ - pecl install redis && \ - docker-php-ext-enable redis && \ - apk del .phpize-deps +RUN install-php-extensions \ + imagick \ + intl \ + mailparse \ + opcache \ + pdo_pgsql \ + pgsql \ + redis \ + soap \ + zip RUN apk add --no-cache \ openjdk11-jre && \ @@ -90,36 +70,6 @@ RUN apk add --no-cache \ npm==10.24.1-r0 && \ npm install -g less -RUN mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" - -COPY --from=composer /app/ /app/ - -COPY docker/php-cli/litus.ini /usr/local/etc/php/conf.d/ -COPY docker/php-cli/entrypoint.sh / - -ENTRYPOINT ["/entrypoint.sh"] - -FROM php:8.1.9-fpm-alpine AS php-fpm - -ARG APPLICATION_ENV=development -ENV APPLICATION_ENV=${APPLICATION_ENV} -ARG COMMIT_SHA -ENV COMMIT_SHA=${COMMIT_SHA} - -RUN apk add --no-cache \ - icu \ - imagemagick \ - libgomp \ - libpq \ - libxml2 \ - libzip \ - openjdk11-jre - -RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main --update-cache \ - nodejs==10.24.1-r0 \ - npm==10.24.1-r0 && \ - npm install -g less - RUN curl -fsSL -o /tmp/fop-2.7-bin.tar.gz https://downloads.apache.org/xmlgraphics/fop/binaries/fop-2.7-bin.tar.gz && \ tar --strip-components=1 -C /opt -xzf /tmp/fop-2.7-bin.tar.gz fop-2.7/fop && \ rm /tmp/fop-2.7-bin.tar.gz @@ -134,13 +84,10 @@ RUN mkdir -p /app/public/_assetic && \ mkdir -p /app/public/_br/img && \ chown -R www-data:www-data /app -COPY --from=php-cli --chown=www-data:www-data /app/ /app/ - -COPY --from=php-cli /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ -COPY --from=php-cli /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ +COPY --from=composer /app/ /app/ -COPY docker/php-fpm/litus.ini /usr/local/etc/php/conf.d/ -COPY docker/php-fpm/opcache.ini /usr/local/etc/php/conf.d/ +COPY docker/frankenphp/litus.ini /usr/local/etc/php/conf.d/ +COPY docker/frankenphp/entrypoint.sh / VOLUME ["/app/public/_assetic"] VOLUME ["/app/public/_common/profile"] @@ -151,23 +98,4 @@ VOLUME ["/app/public/_br/img"] VOLUME ["/data"] -FROM scratch - -COPY --from=caddy /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=caddy /usr/bin/caddy /usr/bin/ - -COPY --from=composer /app/public/ /app/public/ - -COPY docker/caddy/Caddyfile /etc/caddy/ - -VOLUME ["/app/public/_assetic"] -VOLUME ["/app/public/_common/profile"] -VOLUME ["/app/public/_gallery/albums"] -VOLUME ["/app/public/_publications/pdf"] -VOLUME ["/app/public/_publications/html"] -VOLUME ["/app/public/_br/img"] - -EXPOSE 8080 - -ENTRYPOINT ["caddy"] -CMD ["run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/composer.json b/composer.json index 1599947397..eeecb2517b 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,12 @@ "squizlabs/php_codesniffer": "^3.3", "slevomat/coding-standard": "^6.1" }, + "config": { + "allow-plugins": { + "laminas/laminas-dependency-plugin": true, + "phpstan/extension-installer": true + } + }, "autoload": { "psr-4": { "Migrations\\": "migrations", diff --git a/docker-compose.yml b/docker-compose.yml index 91bb0d0128..9138964656 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,53 +10,8 @@ volumes: services: litus: image: litusproject/litus:latest - container_name: litus-litus-1 build: context: . - depends_on: - - php-fpm - ports: - - 127.0.0.1:8080:8080 - volumes: - - assetic:/app/public/_assetic - restart: unless-stopped - - pgweb: - image: sosedoff/pgweb:latest - container_name: litus-pgweb-1 - depends_on: - - postgres - environment: - - DATABASE_URL=postgres://litus:huQeyU8te3aXusaz@postgres:5432/litus?sslmode=disable - ports: - - 127.0.0.1:8081:8081 - restart: unless-stopped - - php-cli: - image: litusproject/litus:php-cli-latest - build: - context: . - target: php-cli - depends_on: - - postgres - - redis - environment: - LITUS_DATABASE_HOST: postgres - LITUS_DATABASE_USER: litus - LITUS_DATABASE_PASSWORD: huQeyU8te3aXusaz - LITUS_DATABASE_DBNAME: litus - - LITUS_REDIS_HOST: redis - - php-fpm: - image: litusproject/litus:php-fpm-latest - container_name: litus-php-fpm-1 - build: - context: . - target: php-fpm - depends_on: - - postgres - - redis environment: LITUS_DATABASE_HOST: postgres LITUS_DATABASE_USER: litus @@ -64,13 +19,14 @@ services: LITUS_DATABASE_DBNAME: litus LITUS_REDIS_HOST: redis + ports: + - 127.0.0.1:8080:80 volumes: - assetic:/app/public/_assetic restart: unless-stopped postgres: image: postgres:latest - container_name: litus-postgres-1 environment: POSTGRES_USER: litus POSTGRES_PASSWORD: huQeyU8te3aXusaz @@ -79,5 +35,4 @@ services: redis: image: redis:latest - container_name: litus-redis-1 restart: unless-stopped diff --git a/docker/caddy/Caddyfile b/docker/caddy/Caddyfile deleted file mode 100644 index 260cb9316a..0000000000 --- a/docker/caddy/Caddyfile +++ /dev/null @@ -1,7 +0,0 @@ -:8080 - -root * /app/public - -file_server -php_fastcgi php-fpm:9000 -try_files {path} {path}/ /app/public/index.php?{query} diff --git a/docker/php-cli/entrypoint.sh b/docker/frankenphp/entrypoint.sh similarity index 90% rename from docker/php-cli/entrypoint.sh rename to docker/frankenphp/entrypoint.sh index 097233b56a..fb2b4589d4 100755 --- a/docker/php-cli/entrypoint.sh +++ b/docker/frankenphp/entrypoint.sh @@ -19,7 +19,7 @@ case "$1" in ;; "") - exit 0 + docker-php-entrypoint --config /etc/Caddyfile ;; *) diff --git a/docker/php-fpm/litus.ini b/docker/frankenphp/litus.ini similarity index 100% rename from docker/php-fpm/litus.ini rename to docker/frankenphp/litus.ini diff --git a/docker/load_db_docker.sh b/docker/load_db_docker.sh deleted file mode 100755 index d0ff66c64d..0000000000 --- a/docker/load_db_docker.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -echo "yip yip" -# Change the working dir to the root of the app -pushd .. -# Stop script on error -set -e - -# Run as root -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit -fi - -if [[ $# -ne 1 ]];then - if [ -f "/tmp/db_dump" ];then - echo "Cached database dump (/tmp/db_dump) detected, do you want to load this database?" - select yn in "Yes" "No"; do - case $yn in - Yes ) - filename="/tmp/db_dump" - break;; - No ) - break;; - esac - done - fi - if [ -z $filename ]; then - echo "Do you want to use a local stored database?" - select yn in "Yes" "No"; do - case $yn in - Yes ) - echo "No file given, please give the file name of the database dump" - read filename - if [ ! -f "$filename" ]; then - echo "File does not exist!" - exit; - fi - break;; - No ) - echo "Database server:" - read database_server - echo "Server user:" - read database_user - ssh -t $database_user@$database_server "sudo runuser -l postgres -c 'pg_dump litus > /tmp/db_dump'" - scp $database_user@$database_server:/tmp/db_dump /tmp - ssh -t $database_user@$database_server "sudo rm /tmp/db_dump" - filename="/tmp/db_dump" - break;; - esac - done - fi - else - filename=$1 -fi - -bn=$(basename $filename) - -# Copy over database -docker cp $filename litus-postgres-1:/root - -# Delete all tables from database -docker exec litus-postgres-1 psql -U litus -c " -DROP SCHEMA IF EXISTS public CASCADE; -CREATE SCHEMA public AUTHORIZATION litus; -GRANT ALL ON SCHEMA public TO public; -GRANT ALL ON SCHEMA public TO litus;" -# Load new data -docker exec litus-postgres-1 /bin/sh -c "psql -h 127.0.0.1 -U litus -d litus < /root/$bn" - -# Set shibboleth url -docker exec litus-postgres-1 psql -U litus -c " -UPDATE general_config SET value='' WHERE key='shibboleth_url';" - -popd diff --git a/docker/php-cli/litus.ini b/docker/php-cli/litus.ini deleted file mode 100644 index ed5f00de58..0000000000 --- a/docker/php-cli/litus.ini +++ /dev/null @@ -1,4 +0,0 @@ -; This directive determines which super global arrays are registered when PHP -; starts up. G,P,C,E & S are abbreviations for the following respective super -; globals: GET, POST, COOKIE, ENV and SERVER. -variables_order = "EGPCS" diff --git a/docker/php-fpm/opcache.ini b/docker/php-fpm/opcache.ini deleted file mode 100644 index 38cd35e9ff..0000000000 --- a/docker/php-fpm/opcache.ini +++ /dev/null @@ -1,36 +0,0 @@ -[opcache] - -; OPcache On/Off switch. When set to Off, code is not optimized. -opcache.enable=1 - -; The OPcache shared memory storage size. The amount of memory for storing -; precompiled PHP code in Mbytes. -opcache.memory_consumption=192 - -; The amount of memory for interned strings in Mbytes. -opcache.interned_strings_buffer=16 - -; The maximum number of keys (scripts) in the OPcache hash table. The number is -; actually the first one in the following set of prime numbers that is bigger -; than the one supplied: { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, -; 130987, 262237, 524521, 1048793 }. Only numbers between 200 and 1000000 are -; allowed. -opcache.max_accelerated_files=10000 - -; The maximum percentage of "wasted" memory until a restart is scheduled. -opcache.max_wasted_percentage=10 - -; When disabled, you must reset the OPcache manually or restart the webserver -; for changes to the filesystem to take effect. The frequency of the check is -; controlled by the directive "opcache.revalidate_freq". -opcache.validate_timestamps=1 - -; 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=0 - -; If enabled, a fast shutdown sequence is used for the accelerated code. The -; fast shutdown sequence doesn't free each allocated block, but lets the Zend -; Engine Memory Manager do the work. -opcache.fast_shutdown=1 diff --git a/docker/run_dev_docker.sh b/docker/run_dev_docker.sh deleted file mode 100755 index 6876c90b55..0000000000 --- a/docker/run_dev_docker.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -echo "yip yip" -function trap_ctrlc (){ - # perform cleanup here - echo "Ctrl-C caught...performing clean up" - docker-compose down - echo "Goodbye" - exit 2 -} - -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit -fi -# Change working dir to the app root -pushd .. - -docker build -t litus . -#docker-compose -f docker-compose.yml -f docker/docker-compose.dev.yml up -d -docker-compose -f docker-compose.yml up -d -#docker exec -u 0 -it litus-php-fpm-1 chown -R www-data:www-data /app -trap "trap_ctrlc" 2 -docker-compose run --rm php-cli init -# docker-compose logs -f - -# echo "Listening for updates..." -# find . | entr sh -c 'docker exec -u 0 -it litus-php-fpm-1 chown -R www-data:www-data /app' -find . | entr sh -c 'echo "Change Detected...";docker cp . litus-php-fpm-1:/app; docker exec -u 0 -it litus-php-fpm-1 chown -R www-data:www-data /app; echo "Updated."' - -echo "Goodbye." -popd