diff --git a/.gitignore b/.gitignore index d41d005..978a035 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ composer.phar # ignore .test folders .test +#ignore apple files +.DS_Store + # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file # composer.lock diff --git a/composer.json b/composer.json index 8d515fd..b72adcc 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,11 @@ "require": {}, "scripts": { "setup": "php public/index.php run:setup", - "serve-dev": "podman-compose up -d --build --build-arg INSTALL_XDEBUG=true", - "stop-serve-dev": "podman-compose down", - "serve": "docker-compose up -d --build", + "docker-dev-init": "docker-compose build --build-arg INSTALL_XDEBUG=true", + "serve-dev": "docker-compose up -d", + "stop-serve-dev": "docker-compose down", + "docker-init": "docker-compose build --build-arg INSTALL_XDEBUG=false", + "serve": "docker-compose up -d", "stop-serve": "docker-compose down" } } diff --git a/docker-compose.yml b/docker-compose.yml index 7695f9d..f2e57a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,55 +1,36 @@ -version: "3.8" - services: php: build: context: . dockerfile: docker/php/Dockerfile args: - INSTALL_XDEBUG: "false" + INSTALL_XDEBUG: ${ENABLE_XDEBUG} + environment: + ENABLE_XDEBUG: ${ENABLE_XDEBUG} container_name: app-php working_dir: /var/www/html volumes: + - ./docker/php/entrypoint.sh:/entrypoint.sh - ./:/var/www/html:Z extra_hosts: - "host.docker.internal:host-gateway" - entrypoint: > - sh -c " - if [ ! -d vendor ]; then - composer install --no-dev --optimize-autoloader; - php scripts/setup.php; - fi; - php-fpm - " + entrypoint: [ "sh", "/entrypoint.sh" ] networks: - - appnet + - apps web: image: docker.io/library/httpd:2.4 container_name: app-web depends_on: [php] ports: - - "8080:80" + - "8000:80" volumes: + - ./docker/apache/entrypoint.sh:/entrypoint.sh - ./public:/usr/local/apache2/htdocs:Z - ./docker/apache/vhost.conf:/usr/local/apache2/conf/extra/vhost.conf:ro,Z - command: > - sh -c " - # ───────── Module laden ───────── - echo 'LoadModule rewrite_module modules/mod_rewrite.so' \ - >> /usr/local/apache2/conf/httpd.conf; - echo 'LoadModule proxy_module modules/mod_proxy.so' \ - >> /usr/local/apache2/conf/httpd.conf; - echo 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so' \ - >> /usr/local/apache2/conf/httpd.conf; - # ───────── VHost aktivieren ───────── - echo 'Include conf/extra/vhost.conf' \ - >> /usr/local/apache2/conf/httpd.conf; - httpd-foreground - " + command: [ "sh", "/entrypoint.sh" ] networks: - - appnet + - apps networks: - appnet: - driver: bridge \ No newline at end of file + apps: \ No newline at end of file diff --git a/docker/apache/entrypoint.sh b/docker/apache/entrypoint.sh new file mode 100755 index 0000000..73d92fd --- /dev/null +++ b/docker/apache/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +echo "🚀 Apache Setup beginnt..." + +# ───────── Module laden ───────── +echo '📦 Lade Apache-Module...' +echo 'LoadModule rewrite_module modules/mod_rewrite.so' >> /usr/local/apache2/conf/httpd.conf +echo 'LoadModule proxy_module modules/mod_proxy.so' >> /usr/local/apache2/conf/httpd.conf +echo 'LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so' >> /usr/local/apache2/conf/httpd.conf + +# ───────── VHost aktivieren ───────── +echo '🔧 Aktiviere vhost.conf...' +echo 'Include conf/extra/vhost.conf' >> /usr/local/apache2/conf/httpd.conf + +echo "✅ Starte Apache im Vordergrund..." +exec httpd-foreground \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 2584206..216d601 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -6,9 +6,13 @@ ARG INSTALL_XDEBUG=false # System-Tools für pecl RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - git unzip \ + git unzip wget curl \ && rm -rf /var/lib/apt/lists/* +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && composer --version + # Conditionally install Xdebug RUN if [ "$INSTALL_XDEBUG" = "true" ]; then \ pecl install xdebug \ diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh new file mode 100755 index 0000000..1d3254a --- /dev/null +++ b/docker/php/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +echo "🚀 Starte Container Setup..." + +# Vendor check +if [ ! -d vendor ]; then + echo "📦 Installiere Composer-Abhängigkeiten..." + composer install --no-dev --optimize-autoloader + + echo "⚙️ Führe Setup-Script aus..." + php public/index.php +fi + +echo "✅ Starte PHP-FPM..." +exec php-fpm \ No newline at end of file diff --git a/example.env b/example.env index 6b4e7d2..46e29b4 100644 --- a/example.env +++ b/example.env @@ -1,4 +1,10 @@ +# Configure if Docker Image should include the xdebug extension or not +ENABLE_XDEBUG=true + +# define the application context APP_CONTEXT="Production" + +# some 3rd party environment configurations HOLIDAY_SERVER="https://get.api-feiertage.de?years=$currentYear&states=nw" SERVER="https://your.next.cloud/apps/tables/api/1/tables/[$yourTableId]/rows" LOGIN="yourlogin@next.cloud:YOURPASSWORD" \ No newline at end of file diff --git a/src/Application.php b/src/Application.php index 533b77a..1e8c77d 100644 --- a/src/Application.php +++ b/src/Application.php @@ -103,6 +103,7 @@ class Application { } private static function initConsole() { + echo "I should do something"; } @@ -138,6 +139,7 @@ class Application { } private static function runConsole() { + echo "I automatically know that I run on the console"; }