From a9189dce916b5a4f646a19e53af11182252a5694 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:02:26 -0500 Subject: [PATCH 01/19] refactor: update Docker configuration and environment variables for consistency --- .env.example | 5 +---- docker-compose.yml | 20 ++++++++++++-------- docker/Dockerfile | 28 +++++++++++++++++----------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/.env.example b/.env.example index e892f6a..98c1e66 100644 --- a/.env.example +++ b/.env.example @@ -10,7 +10,7 @@ DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=phenix DB_USERNAME=phenix -DB_PASSWORD=secret +DB_PASSWORD= LOG_CHANNEL=stream @@ -21,6 +21,3 @@ CORS_ORIGIN= REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_PASSWORD=null - -USER_UID=1000 -USER_GID=1000 diff --git a/docker-compose.yml b/docker-compose.yml index dffd3bd..1bcef15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,19 +2,20 @@ services: app: build: context: ./docker - args: - - USER_UID=${USER_UID} - - USER_GID=${USER_GID} + target: development volumes: - - .:/usr/src/phenix:rw - working_dir: /usr/src/phenix + - .:/var/www:rw + working_dir: /var/www extra_hosts: - 'host.docker.internal:host-gateway' environment: - - APP_PORT=${APP_PORT} - - APP_ENV=${APP_ENV} + - APP_PORT=${APP_PORT:-8080} + - APP_ENV=${APP_ENV:-development} ports: - - '${APP_PORT}:${APP_PORT}' + - '${APP_PORT:-8080}:${APP_PORT:-8080}' + networks: + - phenix + mysql: image: mysql:8.0 ports: @@ -25,6 +26,9 @@ services: MYSQL_USER: '${DB_USERNAME}' MYSQL_PASSWORD: '${DB_PASSWORD}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 + networks: + - phenix + networks: phenix: driver: bridge \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 42338a0..9c5c302 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,22 +1,28 @@ -FROM php:8.2-cli -WORKDIR /usr/src/phenix +FROM php:8.2-cli AS development -ARG USER_UID -ARG USER_GID +WORKDIR /var/www/ -RUN groupadd -g ${USER_GID} phenix_group && useradd -ms /bin/bash -u ${USER_UID} -g ${USER_GID} phenix_user +RUN apt-get update \ + && apt-get install -y curl \ + && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* RUN docker-php-ext-install pcntl pdo pdo_mysql -RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ - apt-get install -y nodejs +COPY . /var/www/ -USER phenix_user +FROM php:8.2-cli AS production -COPY . /usr/src/phenix +WORKDIR /var/www/ -ENV APP_PORT=${APP_PORT} +RUN docker-php-ext-install pcntl pdo pdo_mysql + +COPY . /var/www/ + +USER www-data -EXPOSE ${APP_PORT} +EXPOSE 8080 ENTRYPOINT ["docker/entrypoint.sh"] From a3f2fb1acc97c78c5c89330aff079cb99f058a77 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:06:11 -0500 Subject: [PATCH 02/19] refactor: reorganize Dockerfile stages and improve package installation --- docker/Dockerfile | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9c5c302..8eb6a5f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,28 +1,40 @@ -FROM php:8.2-cli AS development +FROM php:8.2-cli AS base WORKDIR /var/www/ RUN apt-get update \ - && apt-get install -y curl \ - && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ - && apt-get install -y nodejs \ + && apt-get install -y curl git unzip \ + && docker-php-ext-install pcntl pdo pdo_mysql \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN docker-php-ext-install pcntl pdo pdo_mysql +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +FROM base AS development + +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && apt-get install -y nodejs COPY . /var/www/ -FROM php:8.2-cli AS production +RUN composer install --no-scripts --no-autoloader -WORKDIR /var/www/ +RUN composer dump-autoload --optimize -RUN docker-php-ext-install pcntl pdo pdo_mysql +EXPOSE ${APP_PORT:-1337} + +ENTRYPOINT ["docker/entrypoint.sh"] + +FROM base AS production COPY . /var/www/ +RUN composer install --no-dev --optimize-autoloader --no-scripts \ + && chown -R www-data:www-data /var/www \ + && chmod -R 755 /var/www/storage + USER www-data -EXPOSE 8080 +EXPOSE ${APP_PORT:-1337} ENTRYPOINT ["docker/entrypoint.sh"] From 4679ca12dbdc5f22d025a81f6c18940b79d1616c Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:07:10 -0500 Subject: [PATCH 03/19] refactor: update docker-compose configuration for app and mysql services --- docker-compose.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1bcef15..4e02366 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,27 @@ services: app: build: - context: ./docker + context: . + dockerfile: docker/Dockerfile target: development volumes: - .:/var/www:rw + - /var/www/vendor working_dir: /var/www extra_hosts: - 'host.docker.internal:host-gateway' environment: - - APP_PORT=${APP_PORT:-8080} + - APP_PORT=${APP_PORT:-1337} - APP_ENV=${APP_ENV:-development} + - DB_HOST=mysql + - DB_PORT=3306 + - DB_DATABASE=${DB_DATABASE} + - DB_USERNAME=${DB_USERNAME} + - DB_PASSWORD=${DB_PASSWORD} ports: - - '${APP_PORT:-8080}:${APP_PORT:-8080}' + - '${APP_PORT:-1337}:${APP_PORT:-1337}' + depends_on: + - mysql networks: - phenix @@ -26,9 +35,14 @@ services: MYSQL_USER: '${DB_USERNAME}' MYSQL_PASSWORD: '${DB_PASSWORD}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - mysql_data:/var/lib/mysql networks: - phenix +volumes: + mysql_data: + networks: phenix: driver: bridge \ No newline at end of file From 32ac6781c787e53373a3629029d8c452ea9aabdd Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:08:17 -0500 Subject: [PATCH 04/19] refactor: update entrypoint script to use bash and improve environment handling --- docker/entrypoint.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 29a2f45..e5888b4 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,7 +1,26 @@ -#!/bin/sh +#!/bin/bash + +set -e + +chmod +x ./phenix + +if [ "$APP_ENV" != "production" ]; then + echo "Waiting for MySQL to be ready..." + while ! nc -z mysql 3306; do + sleep 1 + done + echo "MySQL is ready!" +fi + +if [ "$APP_ENV" = "development" ]; then + echo "Running migrations..." + ./phenix migrate:run || true +fi if [ "$APP_ENV" = "production" ]; then - php public/index.php --host=0.0.0.0 --port=${APP_PORT} + echo "Starting production server..." + php public/index.php --host=0.0.0.0 --port=${APP_PORT:-1337} else - php ./server --host=0.0.0.0 --port=${APP_PORT} + echo "Starting development server with file watcher..." + php ./server --host=0.0.0.0 --port=${APP_PORT:-1337} fi \ No newline at end of file From 346f510eca470d3fbeb7b5e628783a0d584440a3 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:12:17 -0500 Subject: [PATCH 05/19] refactor: change environment target from development to local in Docker configuration --- docker-compose.yml | 2 +- docker/Dockerfile | 2 +- docker/entrypoint.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4e02366..d65d027 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: docker/Dockerfile - target: development + target: local volumes: - .:/var/www:rw - /var/www/vendor diff --git a/docker/Dockerfile b/docker/Dockerfile index 8eb6a5f..df0ba19 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update \ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -FROM base AS development +FROM base AS local RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y nodejs diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e5888b4..48cb1df 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,7 +12,7 @@ if [ "$APP_ENV" != "production" ]; then echo "MySQL is ready!" fi -if [ "$APP_ENV" = "development" ]; then +if [ "$APP_ENV" = "local" ]; then echo "Running migrations..." ./phenix migrate:run || true fi From 6434677089b2a10d95b682992b32e1d7316dc514 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:22:39 -0500 Subject: [PATCH 06/19] refactor: add .dockerignore file to exclude unnecessary files from Docker context --- .dockerignore | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4ff7ed4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,49 @@ +.git +.gitignore +.gitattributes + +Dockerfile +docker-compose.yml +.dockerignore + +README.md +CHANGELOG.md +LICENSE.md +docs/ + +.vscode/ +.idea/ +*.swp +*.swo + +.DS_Store +Thumbs.db + +storage/logs/* +storage/framework/logs/* +storage/app/public/* +storage/framework/cache/* +storage/framework/sessions/* +storage/framework/testing/* +storage/framework/views/* + +node_modules/ +vendor/ + +.env + +build/ +coverage/ + +*.tmp +*.log +*.pid +*.seed +*.pid.lock + +.phpunit.result.cache +.pest +.php_cs.cache + +dist/ +public/build/ From 856b343b4a69d78bb03a1e663f953c9e902f0af3 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:30:29 -0500 Subject: [PATCH 07/19] refactor: simplify entrypoint script by removing MySQL readiness check for local environment --- docker/entrypoint.sh | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 48cb1df..4c5b3b7 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -4,18 +4,8 @@ set -e chmod +x ./phenix -if [ "$APP_ENV" != "production" ]; then - echo "Waiting for MySQL to be ready..." - while ! nc -z mysql 3306; do - sleep 1 - done - echo "MySQL is ready!" -fi - -if [ "$APP_ENV" = "local" ]; then - echo "Running migrations..." - ./phenix migrate:run || true -fi +echo "Running migrations..." +./phenix migrate:run || true if [ "$APP_ENV" = "production" ]; then echo "Starting production server..." From d7baef3ebac0d59088b49f99651726eb3d26a6bc Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 11:39:45 -0500 Subject: [PATCH 08/19] refactor: remove unnecessary executable permission change for phenix in entrypoint script --- docker/entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4c5b3b7..2ceb2a2 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,8 +2,6 @@ set -e -chmod +x ./phenix - echo "Running migrations..." ./phenix migrate:run || true From f5379fe53c6352aa686be5faea56fbabd786616e Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 18:00:06 -0500 Subject: [PATCH 09/19] refactor: set default values for MySQL environment variables in docker-compose --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d65d027..c0b2024 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,9 +31,9 @@ services: - "${MYSQL_PORT:-3307}:3306" environment: MYSQL_ROOT_HOST: "%" - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_DATABASE: '${DB_DATABASE:-phenix}' + MYSQL_USER: '${DB_USERNAME:-phenix}' + MYSQL_PASSWORD: '${DB_PASSWORD:-secret}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: - mysql_data:/var/lib/mysql From 1b39555813022c151e1ff0f8b5f3c98f8d65768b Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Mon, 25 Aug 2025 18:01:19 -0500 Subject: [PATCH 10/19] refactor: update MySQL username in environment configuration to 'root' --- .env.example | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 98c1e66..a0e04ad 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=phenix -DB_USERNAME=phenix +DB_USERNAME=root DB_PASSWORD= LOG_CHANNEL=stream diff --git a/docker-compose.yml b/docker-compose.yml index c0b2024..a6939b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: environment: MYSQL_ROOT_HOST: "%" MYSQL_DATABASE: '${DB_DATABASE:-phenix}' - MYSQL_USER: '${DB_USERNAME:-phenix}' + MYSQL_USER: '${DB_USERNAME:-root}' MYSQL_PASSWORD: '${DB_PASSWORD:-secret}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: From c833f59a684ed1b5666257268c885b9a4949ebba Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 10:39:43 -0500 Subject: [PATCH 11/19] refactor: remove .env from .dockerignore to allow environment variable configuration --- .dockerignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4ff7ed4..c024240 100644 --- a/.dockerignore +++ b/.dockerignore @@ -30,8 +30,6 @@ storage/framework/views/* node_modules/ vendor/ -.env - build/ coverage/ From 1abd4efd090e91e0235ab143720790712515aaad Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 10:40:11 -0500 Subject: [PATCH 12/19] refactor: improve database configuration --- .env.example | 2 +- docker-compose.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index a0e04ad..98c1e66 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=phenix -DB_USERNAME=root +DB_USERNAME=phenix DB_PASSWORD= LOG_CHANNEL=stream diff --git a/docker-compose.yml b/docker-compose.yml index a6939b3..d36d887 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,12 +12,12 @@ services: - 'host.docker.internal:host-gateway' environment: - APP_PORT=${APP_PORT:-1337} - - APP_ENV=${APP_ENV:-development} + - APP_ENV=${APP_ENV:-local} - DB_HOST=mysql - DB_PORT=3306 - - DB_DATABASE=${DB_DATABASE} - - DB_USERNAME=${DB_USERNAME} - - DB_PASSWORD=${DB_PASSWORD} + - DB_DATABASE=${DB_DATABASE:-phenix} + - DB_USERNAME=${DB_USERNAME:-phenix} + - DB_PASSWORD=${DB_PASSWORD:-secret} ports: - '${APP_PORT:-1337}:${APP_PORT:-1337}' depends_on: @@ -32,7 +32,7 @@ services: environment: MYSQL_ROOT_HOST: "%" MYSQL_DATABASE: '${DB_DATABASE:-phenix}' - MYSQL_USER: '${DB_USERNAME:-root}' + MYSQL_USER: '${DB_USERNAME:-phenix}' MYSQL_PASSWORD: '${DB_PASSWORD:-secret}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: From c7d386d790ecf8f0cb1ae3359e331898c1e2637f Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 10:41:23 -0500 Subject: [PATCH 13/19] refactor: add .env to .dockerignore to prevent environment variable exposure --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index c024240..4ff7ed4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -30,6 +30,8 @@ storage/framework/views/* node_modules/ vendor/ +.env + build/ coverage/ From 003e0f6ba7eda4acc45d55c217b914e86dcbbe3f Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 10:46:12 -0500 Subject: [PATCH 14/19] refactor: use static function syntax for environment variable defaults in configuration files --- config/cors.php | 2 +- config/logging.php | 2 +- config/session.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/cors.php b/config/cors.php index d191010..105b1ab 100644 --- a/config/cors.php +++ b/config/cors.php @@ -1,7 +1,7 @@ env('CORS_ORIGIN', fn (): array => ['http://localhost', 'http://127.0.0.1']), + 'origins' => env('CORS_ORIGIN', static fn (): array => ['http://localhost', 'http://127.0.0.1']), 'allowed_methods' => ['GET', 'POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE'], 'max_age' => 8600, 'allowed_headers' => ['X-Request-Headers', 'Content-Type', 'Authorization', 'X-Requested-With'], diff --git a/config/logging.php b/config/logging.php index cc0d9b6..cb63722 100644 --- a/config/logging.php +++ b/config/logging.php @@ -3,7 +3,7 @@ declare(strict_types=1); return [ - 'default' => env('LOG_CHANNEL', fn (): string => 'file'), + 'default' => env('LOG_CHANNEL', static fn (): string => 'file'), /* |-------------------------------------------------------------------------- diff --git a/config/session.php b/config/session.php index d229735..87ed685 100644 --- a/config/session.php +++ b/config/session.php @@ -15,9 +15,9 @@ | */ - 'driver' => env('SESSION_DRIVER', fn (): string => 'redis'), + 'driver' => env('SESSION_DRIVER', static fn (): string => 'redis'), - 'lifetime' => env('SESSION_LIFETIME', fn () => 120), + 'lifetime' => env('SESSION_LIFETIME', static fn (): int => 120), /* |-------------------------------------------------------------------------- From 39fc14978d52356ab971f5c24154dfc04997eeda Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 17:56:34 -0500 Subject: [PATCH 15/19] refactor: update docker-compose and Dockerfile for improved structure and Redis integration --- docker-compose.yml | 21 ++++++++++++++++++--- docker/Dockerfile | 31 ++++++++++++++++--------------- docker/entrypoint.sh | 5 +---- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d36d887..b94c63f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,9 @@ services: dockerfile: docker/Dockerfile target: local volumes: - - .:/var/www:rw - - /var/www/vendor - working_dir: /var/www + - .:/var/www/html:rw + - /var/www/html/vendor + working_dir: /var/www/html extra_hosts: - 'host.docker.internal:host-gateway' environment: @@ -18,10 +18,14 @@ services: - DB_DATABASE=${DB_DATABASE:-phenix} - DB_USERNAME=${DB_USERNAME:-phenix} - DB_PASSWORD=${DB_PASSWORD:-secret} + - REDIS_HOST=redis + - REDIS_PORT=6379 + - REDIS_PASSWORD=${REDIS_PASSWORD} ports: - '${APP_PORT:-1337}:${APP_PORT:-1337}' depends_on: - mysql + - redis networks: - phenix @@ -40,8 +44,19 @@ services: networks: - phenix + redis: + image: redis:7-alpine + ports: + - "${REDIS_PORT:-6379}:6379" + command: redis-server --appendonly yes + volumes: + - redis_data:/data + networks: + - phenix + volumes: mysql_data: + redis_data: networks: phenix: diff --git a/docker/Dockerfile b/docker/Dockerfile index df0ba19..a69a17a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,24 +1,25 @@ -FROM php:8.2-cli AS base +FROM serversideup/php:8.2-cli-alpine AS base -WORKDIR /var/www/ +USER root -RUN apt-get update \ - && apt-get install -y curl git unzip \ - && docker-php-ext-install pcntl pdo pdo_mysql \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --no-cache \ + curl \ + git \ + unzip COPY --from=composer:latest /usr/bin/composer /usr/bin/composer FROM base AS local -RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ - && apt-get install -y nodejs +RUN apk add --no-cache nodejs npm -COPY . /var/www/ +COPY --chown=www-data:www-data . /var/www/html -RUN composer install --no-scripts --no-autoloader +RUN chmod -R 755 /var/www/html/storage + +USER www-data +RUN composer install --no-scripts --no-autoloader RUN composer dump-autoload --optimize EXPOSE ${APP_PORT:-1337} @@ -27,14 +28,14 @@ ENTRYPOINT ["docker/entrypoint.sh"] FROM base AS production -COPY . /var/www/ +COPY --chown=www-data:www-data . /var/www/html -RUN composer install --no-dev --optimize-autoloader --no-scripts \ - && chown -R www-data:www-data /var/www \ - && chmod -R 755 /var/www/storage +RUN chmod -R 755 /var/www/html/storage USER www-data +RUN composer install --no-dev --optimize-autoloader --no-scripts + EXPOSE ${APP_PORT:-1337} ENTRYPOINT ["docker/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2ceb2a2..c7313ff 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,10 +1,7 @@ -#!/bin/bash +#!/bin/sh set -e -echo "Running migrations..." -./phenix migrate:run || true - if [ "$APP_ENV" = "production" ]; then echo "Starting production server..." php public/index.php --host=0.0.0.0 --port=${APP_PORT:-1337} From 502bb6575cf83efc2163e79e07db0b7a48af85d4 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 18:03:41 -0500 Subject: [PATCH 16/19] refactor: update database and Redis configuration in .env.example for consistency --- .env.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env.example b/.env.example index 98c1e66..b73e8db 100644 --- a/.env.example +++ b/.env.example @@ -21,3 +21,5 @@ CORS_ORIGIN= REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_PASSWORD=null + +SESSION_DRIVER=local \ No newline at end of file From f4af1f8852d746beea62f8ab01c4cd067daf338b Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Tue, 26 Aug 2025 18:05:20 -0500 Subject: [PATCH 17/19] feat: add .env.example.docker for Docker environment configuration --- .env.example.docker | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .env.example.docker diff --git a/.env.example.docker b/.env.example.docker new file mode 100644 index 0000000..b5fffa1 --- /dev/null +++ b/.env.example.docker @@ -0,0 +1,26 @@ +APP_NAME=Phenix +APP_KEY= +APP_ENV=local +APP_DEBUG=true +APP_URL=http://127.0.0.1 +APP_PORT=1337 + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=phenix +DB_USERNAME=phenix +DB_PASSWORD=secret +MYSQL_PORT=3307 + +LOG_CHANNEL=stream + +QUEUE_DRIVER=parallel + +CORS_ORIGIN= + +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_PASSWORD=null + +SESSION_DRIVER=redis \ No newline at end of file From 69a2c2f14451639bc605578778b250c6813a40d6 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Wed, 27 Aug 2025 08:32:15 -0500 Subject: [PATCH 18/19] refactor: ensure proper newline at end of files in configuration and entrypoint scripts --- .env.example | 2 +- .env.example.docker | 2 +- docker-compose.yml | 2 +- docker/entrypoint.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index b73e8db..58cb2fe 100644 --- a/.env.example +++ b/.env.example @@ -22,4 +22,4 @@ REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_PASSWORD=null -SESSION_DRIVER=local \ No newline at end of file +SESSION_DRIVER=local diff --git a/.env.example.docker b/.env.example.docker index b5fffa1..d54502b 100644 --- a/.env.example.docker +++ b/.env.example.docker @@ -23,4 +23,4 @@ REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD=null -SESSION_DRIVER=redis \ No newline at end of file +SESSION_DRIVER=redis diff --git a/docker-compose.yml b/docker-compose.yml index b94c63f..93eb9de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,4 +60,4 @@ volumes: networks: phenix: - driver: bridge \ No newline at end of file + driver: bridge diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index c7313ff..9828907 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -8,4 +8,4 @@ if [ "$APP_ENV" = "production" ]; then else echo "Starting development server with file watcher..." php ./server --host=0.0.0.0 --port=${APP_PORT:-1337} -fi \ No newline at end of file +fi From 08714c776755408f987c575419528d068dd78be1 Mon Sep 17 00:00:00 2001 From: Omar Barbosa Date: Wed, 27 Aug 2025 08:46:17 -0500 Subject: [PATCH 19/19] refactor: change QUEUE_DRIVER from parallel to database in .env.example.docker --- .env.example.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example.docker b/.env.example.docker index d54502b..0f2aa3b 100644 --- a/.env.example.docker +++ b/.env.example.docker @@ -15,7 +15,7 @@ MYSQL_PORT=3307 LOG_CHANNEL=stream -QUEUE_DRIVER=parallel +QUEUE_DRIVER=database CORS_ORIGIN=