Skip to content
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
APP_NAME=Phenix
APP_KEY=
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1
APP_PORT=1337
Expand All @@ -8,8 +9,8 @@ DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=phenix
DB_USERNAME=root
DB_PASSWORD=
DB_USERNAME=phenix
DB_PASSWORD=secret

LOG_CHANNEL=stream

Expand All @@ -20,3 +21,6 @@ CORS_ORIGIN=
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null

USER_UID=1000
USER_GID=1000
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
app:
build:
context: ./docker
args:
- USER_UID=${USER_UID}
- USER_GID=${USER_GID}
volumes:
- .:/usr/src/phenix:rw
working_dir: /usr/src/phenix
extra_hosts:
- 'host.docker.internal:host-gateway'
environment:
- APP_PORT=${APP_PORT}
- APP_ENV=${APP_ENV}
ports:
- '${APP_PORT}:${APP_PORT}'
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_ALLOW_EMPTY_PASSWORD: 1
networks:
phenix:
driver: bridge
22 changes: 22 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM php:8.2-cli
WORKDIR /usr/src/phenix

ARG USER_UID
ARG USER_GID

RUN groupadd -g ${USER_GID} phenix_group && useradd -ms /bin/bash -u ${USER_UID} -g ${USER_GID} phenix_user

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

USER phenix_user

COPY . /usr/src/phenix

ENV APP_PORT=${APP_PORT}

EXPOSE ${APP_PORT}

ENTRYPOINT ["docker/entrypoint.sh"]
7 changes: 7 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

if [ "$APP_ENV" = "production" ]; then
php public/index.php --host=0.0.0.0 --port=${APP_PORT}
else
php ./server --host=0.0.0.0 --port=${APP_PORT}
fi
9 changes: 6 additions & 3 deletions server
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Dotenv\Dotenv;
use Spatie\Watcher\Watch;
use Symfony\Component\Process\Process;
use Spatie\Watcher\Exceptions\CouldNotStartWatcher;
use Symfony\Component\Process\PhpExecutableFinder;

require_once __DIR__ . '/vendor/autoload.php';

Expand Down Expand Up @@ -92,7 +93,7 @@ class Watcher extends Watch
parent::__construct();

$this->setPaths($paths);
$this->host = $config['APP_URL'] ?? 'http://127.0.0.1';
$this->host = $config['APP_HOST'] ?? '0.0.0.0';
$this->port = $config['APP_PORT'] ?? 1337;
}

Expand Down Expand Up @@ -168,8 +169,10 @@ class Watcher extends Watch
return;
}

$command = "XDEBUG_MODE=off php public/index.php";
$this->serverProcess = Process::fromShellCommandline($command);
$this->serverProcess = new Process(
command:[(new PhpExecutableFinder)->find(), 'public/index.php', "--host={$this->host}", "--port={$this->port}"],
env:['XDEBUG_MODE' => 'off']
);
$this->serverProcess->setTimeout(null);

try {
Expand Down
Loading