From ff3734e02f98a328d9223d28e402444e61a52222 Mon Sep 17 00:00:00 2001 From: GuavaPopper Date: Thu, 11 Jun 2026 21:07:45 +0700 Subject: [PATCH] feat: add Docker Compose setup for Coolify deployment - Dockerfile: php:8.2-apache with pdo_mysql, curl, mod_rewrite - docker-compose.yml: app + MySQL 8.0, healthchecks, named volumes - .dockerignore: exclude .env, .git, uploads, docs - .gitignore: add .env Co-Authored-By: Claude Sonnet 4.6 --- .dockerignore | 8 ++++++++ .gitignore | 1 + Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f0db656 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.env +.git +uploads/* +!uploads/.gitkeep +docs/ +*.md +localguide-DESIGN.md +COOLIFY_DOCKER_COMPOSE_KNOWLEDGE.md diff --git a/.gitignore b/.gitignore index 02905ca..2f23e52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ uploads/* !uploads/.gitkeep localguide-DESIGN.md +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a701867 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM php:8.2-apache + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + && docker-php-ext-install pdo_mysql \ + && rm -rf /var/lib/apt/lists/* + +RUN a2enmod rewrite \ + && echo "ServerName localhost" >> /etc/apache2/apache2.conf \ + && sed -i 's|AllowOverride None|AllowOverride All|g' /etc/apache2/apache2.conf + +COPY . /var/www/html/ + +RUN mkdir -p /var/www/html/uploads \ + && chown -R www-data:www-data /var/www/html \ + && chmod 755 /var/www/html \ + && chmod 777 /var/www/html/uploads + +EXPOSE 80 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..21eb173 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + restart: unless-stopped + expose: + - "80" + environment: + DB_HOST: "${DB_HOST:-db}" + DB_NAME: "${DB_NAME:-webgis_jalan}" + DB_USER: "${DB_USER:-webgis}" + DB_PASS: "${DB_PASS:?Set DB_PASS in Coolify}" + volumes: + - uploads-data:/var/www/html/uploads + depends_on: + db: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://127.0.0.1/ >/dev/null || exit 1"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 30s + + db: + image: mysql:8.0 + restart: unless-stopped + environment: + MYSQL_DATABASE: "${DB_NAME:-webgis_jalan}" + MYSQL_USER: "${DB_USER:-webgis}" + MYSQL_PASSWORD: "${DB_PASS:?Set DB_PASS in Coolify}" + MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?Set DB_ROOT_PASSWORD in Coolify}" + volumes: + - mysql-data:/var/lib/mysql + - ./schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro + healthcheck: + test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -p\"$${MYSQL_ROOT_PASSWORD}\" --silent"] + interval: 5s + timeout: 5s + retries: 20 + start_period: 30s + +volumes: + mysql-data: + uploads-data: