Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9189dc
refactor: update Docker configuration and environment variables for c…
obarbosa89 Aug 25, 2025
a3f2fb1
refactor: reorganize Dockerfile stages and improve package installation
obarbosa89 Aug 25, 2025
4679ca1
refactor: update docker-compose configuration for app and mysql services
obarbosa89 Aug 25, 2025
32ac678
refactor: update entrypoint script to use bash and improve environmen…
obarbosa89 Aug 25, 2025
346f510
refactor: change environment target from development to local in Dock…
obarbosa89 Aug 25, 2025
6434677
refactor: add .dockerignore file to exclude unnecessary files from Do…
obarbosa89 Aug 25, 2025
856b343
refactor: simplify entrypoint script by removing MySQL readiness chec…
obarbosa89 Aug 25, 2025
d7baef3
refactor: remove unnecessary executable permission change for phenix …
obarbosa89 Aug 25, 2025
f5379fe
refactor: set default values for MySQL environment variables in docke…
obarbosa89 Aug 25, 2025
1b39555
refactor: update MySQL username in environment configuration to 'root'
obarbosa89 Aug 25, 2025
c833f59
refactor: remove .env from .dockerignore to allow environment variabl…
obarbosa89 Aug 26, 2025
1abd4ef
refactor: improve database configuration
obarbosa89 Aug 26, 2025
c7d386d
refactor: add .env to .dockerignore to prevent environment variable e…
obarbosa89 Aug 26, 2025
003e0f6
refactor: use static function syntax for environment variable default…
obarbosa89 Aug 26, 2025
39fc149
refactor: update docker-compose and Dockerfile for improved structure…
obarbosa89 Aug 26, 2025
502bb65
refactor: update database and Redis configuration in .env.example for…
obarbosa89 Aug 26, 2025
f4af1f8
feat: add .env.example.docker for Docker environment configuration
obarbosa89 Aug 26, 2025
69a2c2f
refactor: ensure proper newline at end of files in configuration and …
obarbosa89 Aug 27, 2025
08714c7
refactor: change QUEUE_DRIVER from parallel to database in .env.examp…
obarbosa89 Aug 27, 2025
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
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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/
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -22,5 +22,4 @@ REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null

USER_UID=1000
USER_GID=1000
SESSION_DRIVER=local
26 changes: 26 additions & 0 deletions .env.example.docker
Original file line number Diff line number Diff line change
@@ -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=database

CORS_ORIGIN=

REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=null

SESSION_DRIVER=redis
2 changes: 1 addition & 1 deletion config/cors.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'origins' => 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'],
Expand Down
2 changes: 1 addition & 1 deletion config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

return [
'default' => env('LOG_CHANNEL', fn (): string => 'file'),
'default' => env('LOG_CHANNEL', static fn (): string => 'file'),

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),

/*
|--------------------------------------------------------------------------
Expand Down
59 changes: 46 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
services:
app:
build:
context: ./docker
args:
- USER_UID=${USER_UID}
- USER_GID=${USER_GID}
context: .
dockerfile: docker/Dockerfile
target: local
volumes:
- .:/usr/src/phenix:rw
working_dir: /usr/src/phenix
- .:/var/www/html:rw
- /var/www/html/vendor
working_dir: /var/www/html
extra_hosts:
- 'host.docker.internal:host-gateway'
environment:
- APP_PORT=${APP_PORT}
- APP_ENV=${APP_ENV}
- APP_PORT=${APP_PORT:-1337}
- APP_ENV=${APP_ENV:-local}
- DB_HOST=mysql
- DB_PORT=3306
- 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}:${APP_PORT}'
- '${APP_PORT:-1337}:${APP_PORT:-1337}'
depends_on:
- mysql
- redis
networks:
- phenix

mysql:
image: mysql:8.0
ports:
- "${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
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:
driver: bridge
driver: bridge
43 changes: 31 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
FROM php:8.2-cli
WORKDIR /usr/src/phenix
FROM serversideup/php:8.2-cli-alpine AS base

ARG USER_UID
ARG USER_GID
USER root

RUN groupadd -g ${USER_GID} phenix_group && useradd -ms /bin/bash -u ${USER_UID} -g ${USER_GID} phenix_user
RUN apk add --no-cache \
curl \
git \
unzip

RUN docker-php-ext-install pcntl pdo pdo_mysql
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
FROM base AS local

USER phenix_user
RUN apk add --no-cache nodejs npm

COPY . /usr/src/phenix
COPY --chown=www-data:www-data . /var/www/html

ENV APP_PORT=${APP_PORT}
RUN chmod -R 755 /var/www/html/storage

EXPOSE ${APP_PORT}
USER www-data

RUN composer install --no-scripts --no-autoloader
RUN composer dump-autoload --optimize

EXPOSE ${APP_PORT:-1337}

ENTRYPOINT ["docker/entrypoint.sh"]

FROM base AS production

COPY --chown=www-data:www-data . /var/www/html

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"]
10 changes: 7 additions & 3 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/sh

set -e

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}
fi
echo "Starting development server with file watcher..."
php ./server --host=0.0.0.0 --port=${APP_PORT:-1337}
fi
Loading