From 5a54fdcfdec7cae91292b3b4e920c02093ee346f Mon Sep 17 00:00:00 2001 From: Ricardo Monla Date: Wed, 3 Jun 2026 15:58:27 -0300 Subject: [PATCH] Docker: agregar setup local con NGINX + PHP-FPM y script de control Incluye Dockerfile, docker-compose.yml (puerto 8088), nginx.conf y script _app con --status, --start y --stop para levantar la app localmente. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 6 ++++++ _app | 42 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 27 +++++++++++++++++++++++++++ docker/nginx.conf | 23 +++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 Dockerfile create mode 100755 _app create mode 100644 docker-compose.yml create mode 100644 docker/nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..56a87ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM php:8.2-fpm-alpine + +RUN apk add --no-cache sqlite sqlite-dev \ + && docker-php-ext-install pdo pdo_sqlite + +WORKDIR /var/www/html diff --git a/_app b/_app new file mode 100755 index 0000000..02aa503 --- /dev/null +++ b/_app @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +URL="http://srv-ns8:8088" + +status() { + APP=$(docker compose -f "$DIR/docker-compose.yml" ps --status running --quiet app 2>/dev/null) + WEB=$(docker compose -f "$DIR/docker-compose.yml" ps --status running --quiet web 2>/dev/null) + + if [[ -n "$APP" && -n "$WEB" ]]; then + echo "✔ rm-PAGOs está corriendo → $URL" + elif [[ -z "$APP" && -z "$WEB" ]]; then + echo "✘ rm-PAGOs está detenida." + echo "" + echo " Para levantar:" + echo " cd $DIR && docker compose up -d" + echo " o simplemente:" + echo " $0 --start" + else + echo "⚠ Estado parcial (un contenedor está caído)." + docker compose -f "$DIR/docker-compose.yml" ps + echo "" + echo " Para reiniciar:" + echo " $0 --start" + fi +} + +case "$1" in + --status) status ;; + --start) + echo "Levantando rm-PAGOs..." + docker compose -f "$DIR/docker-compose.yml" up -d + echo "Listo → $URL" + ;; + --stop) + echo "Bajando rm-PAGOs..." + docker compose -f "$DIR/docker-compose.yml" down + ;; + *) + echo "Uso: $0 --status | --start | --stop" + ;; +esac diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0242812 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +services: + app: + build: . + volumes: + - ./pagos:/var/www/html + - db_data:/var/www/html/db + networks: + - pagos_net + + web: + image: nginx:alpine + ports: + - "8088:80" + volumes: + - ./pagos:/var/www/html + - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf + - db_data:/var/www/html/db + depends_on: + - app + networks: + - pagos_net + +volumes: + db_data: + +networks: + pagos_net: diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..544634f --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + root /var/www/html; + index index.html index.php; + + resolver 127.0.0.11 valid=10s; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + set $upstream app:9000; + fastcgi_pass $upstream; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /db/ { + deny all; + } +}