From 0892886167164a01cdbe2e0fa4247aa5e957342a Mon Sep 17 00:00:00 2001 From: Yohanes Seandy Sunjoko Date: Wed, 11 Feb 2026 16:29:58 +0700 Subject: [PATCH] #1 init --- .env.example | 13 +++++-- .gitignore | 1 + composer.json | 1 - config/database.php | 4 +-- docker-compose.yml | 79 +++++++++++++++++++++++++++++++++--------- docker/sail/Dockerfile | 20 ++++++++--- 6 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 .gitignore diff --git a/.env.example b/.env.example index ce1ffe5..16242a1 100644 --- a/.env.example +++ b/.env.example @@ -2,8 +2,8 @@ APP_NAME=jaga APP_ENV=local APP_KEY= APP_DEBUG=true +APP_HOST=localhost APP_URL=http://localhost -APP_PORT=80 APP_LOCALE=en APP_FALLBACK_LOCALE=en @@ -44,7 +44,7 @@ CACHE_PREFIX=jaga_ #MEMCACHED_HOST=127.0.0.1 REDIS_CLIENT=phpredis -REDIS_HOST=127.0.0.1 +REDIS_HOST=jaga-be.redis REDIS_PASSWORD=null REDIS_PORT=6379 @@ -64,3 +64,12 @@ AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false VITE_APP_NAME="${APP_NAME}" +DOCKER_RESTART_POLICY=no + +TRAEFIK_PORT=91 +TRAEFIK_PORT_HTTPS=443 + +WWWUSER=1000 +WWWGROUP=1000 + +SAIL_XDEBUG_MODE=off \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/composer.json b/composer.json index 37c31d6..92a60bd 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "inertiajs/inertia-laravel": "^2.0", "laravel/fortify": "^1.30", "laravel/framework": "^12.0", - "laravel/installer": "*", "laravel/octane": "*", "laravel/tinker": "^2.10.1", "laravel/wayfinder": "^0.1.9" diff --git a/config/database.php b/config/database.php index df933e7..b0786e6 100644 --- a/config/database.php +++ b/config/database.php @@ -157,7 +157,7 @@ return [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), + 'port' => '6379', 'database' => env('REDIS_DB', '0'), 'max_retries' => env('REDIS_MAX_RETRIES', 3), 'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'), @@ -170,7 +170,7 @@ return [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), + 'port' => '6379', 'database' => env('REDIS_CACHE_DB', '1'), 'max_retries' => env('REDIS_MAX_RETRIES', 3), 'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'), diff --git a/docker-compose.yml b/docker-compose.yml index 3f77169..963435f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,46 @@ services: traefik: + restart: "${DOCKER_RESTART_POLICY:-always}" image: traefik:v3.0 container_name: traefik command: + - "--api.insecure=true" + - "--api.dashboard=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" + - "--providers.docker.network=jaga-be.sail.network" - "--entrypoints.web.address=:80" + - "--entrypoints.websecure.address=:443" ports: - - "${APP_PORT:-80}:80" + - "${TRAEFIK_PORT:-80}:80" + - "${TRAEFIK_PORT_HTTPS:-443}:443" + - "8080:8080" # Traefik dashboard volumes: - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - jaga-be.sail.network + labels: + - "traefik.enable=true" + # Dashboard + - "traefik.http.routers.dashboard.rule=Host(`${TRAEFIK_DASHBOARD_HOST:-traefik.localhost}`)" + - "traefik.http.routers.dashboard.service=api@internal" + - "traefik.http.routers.dashboard.entrypoints=web" + - "traefik.http.routers.dashboard.middlewares=auth" + # Middleware for basic auth (optional) + - "traefik.http.middlewares.auth.basicauth.users=${TRAEFIK_AUTH_USERS:-}" - jaga-be-receptionist.app: + receptionist: build: context: ./docker/sail dockerfile: Dockerfile args: WWWGROUP: "${WWWGROUP:-1000}" image: jaga-be/app + container_name: jaga-be.app extra_hosts: - "host.docker.internal:host-gateway" ports: - "${VITE_PORT:-5173}:${VITE_PORT:-5173}" - environment: WWWUSER: "${WWWUSER:-1000}" LARAVEL_SAIL: 1 @@ -30,46 +48,73 @@ services: XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}" XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}" IGNITION_LOCAL_SITES_PATH: "${PWD}" - SUPERVISOR_PHP_COMMAND: "php -d variables_order=EGPCS /var/www/html/artisan octane:swoole --host=0.0.0.0" + SUPERVISOR_PHP_COMMAND: "php -d variables_order=EGPCS /var/www/html/artisan octane:swoole --host=0.0.0.0 --port=8000 --workers=auto" SUPERVISOR_PHP_USER: sail XDG_CONFIG_HOME: /var/www/html/config XDG_DATA_HOME: /var/www/html/data - restart: ${DOCKER_RESTART_POLICY:-always} - volumes: - ".:/var/www/html" - "./storage:/var/www/html/storage" - "./bootstrap/cache:/var/www/html/bootstrap/cache" - jaga-be.app-vendor:/var/www/html/vendor - + - jaga-be.app-node_modules:/var/www/html/node_modules labels: - "traefik.enable=true" - - "traefik.http.routers.receptionist.rule=Host(`api.localhost`)" - - "traefik.http.routers.receptionist.entrypoints=web" - # - "traefik.http.services.receptionist.loadbalancer.server.port=8000" - + # HTTP router + - "traefik.http.routers.receptionist-http.rule=Host(`${APP_HOST:-localhost}`)" + - "traefik.http.routers.receptionist-http.entrypoints=web" + - "traefik.http.routers.receptionist-http.service=receptionist" + # HTTPS router (if you add TLS) + - "traefik.http.routers.receptionist.rule=Host(`${APP_HOST:-localhost}`)" + - "traefik.http.routers.receptionist.entrypoints=websecure" + - "traefik.http.routers.receptionist.service=receptionist" + # Service configuration + - "traefik.http.services.receptionist.loadbalancer.server.port=8000" + - "traefik.http.services.receptionist.loadbalancer.server.scheme=http" + # Health check (optional) + - "traefik.http.services.receptionist.loadbalancer.healthcheck.path=/" + - "traefik.http.services.receptionist.loadbalancer.healthcheck.interval=30s" + - "traefik.http.services.receptionist.loadbalancer.healthcheck.timeout=5s" networks: - jaga-be.sail.network depends_on: - jaga-be.redis + healthcheck: + test: ["CMD", "php", "/var/www/html/artisan", "octane:status", "--no-interaction"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s jaga-be.redis: - image: docker.io/library/redis:7.4 + image: docker.io/library/redis:7.4-alpine restart: ${DOCKER_RESTART_POLICY:-always} container_name: jaga-be.redis - ports: - - "${REDIS_PORT:-6379}:6379" networks: - jaga-be.sail.network + ports: + - "${REDIS_PORT}:6379" volumes: - - ./docker/redis/redis.conf:/usr/local/etc/redis.conf - command: [redis-server, /usr/local/etc/redis.conf] - user: "redis" + - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf + - jaga-be.redis-data:/data + command: redis-server /usr/local/etc/redis/redis.conf --appendonly yes --dir /tmp --protected-mode no --bind 0.0.0.0 + user: "${WWWUSER:-1000}:${WWWGROUP:-1000}" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 30s + timeout: 5s + retries: 3 networks: jaga-be.sail.network: driver: bridge + name: jaga-be.sail.network volumes: jaga-be.app-vendor: + driver: local + jaga-be.app-node_modules: + driver: local + jaga-be.redis-data: + driver: local \ No newline at end of file diff --git a/docker/sail/Dockerfile b/docker/sail/Dockerfile index 59ec228..e102ee7 100644 --- a/docker/sail/Dockerfile +++ b/docker/sail/Dockerfile @@ -34,22 +34,34 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ gd \ mbstring \ xml \ - bcmath \ - redis + bcmath # Swoole extension (CRITICAL) -RUN pecl install swoole \ - && docker-php-ext-enable swoole +RUN pecl install swoole redis \ + && docker-php-ext-enable swoole redis # Composer RUN curl -sS https://getcomposer.org/installer \ | php -- --install-dir=/usr/bin --filename=composer +# Install Node.js (includes npm) +RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \ + && apt-get install -y nodejs \ + && rm -rf /var/lib/apt/lists/* + +# Verify installation +RUN node --version && npm --version + # User RUN groupadd --force -g ${WWWGROUP} ${SUPERVISOR_PHP_USER} \ && useradd -ms /bin/bash --no-user-group \ -g ${WWWGROUP} -u 1337 ${SUPERVISOR_PHP_USER} +# Set proper permissions +RUN mkdir -p /var/www/html/storage /var/www/html/bootstrap/cache +RUN chown -R sail:sail /var/www/html/storage /var/www/html/bootstrap/cache +RUN chmod -Rf 777 /var/www/html/storage /var/www/html/bootstrap/cache + # Supervisor COPY start-container /usr/local/bin/start-container COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -- 2.26.2