diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 20:50:43 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 20:50:43 +0100 |
| commit | d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d (patch) | |
| tree | 618158449863123f6b9527b9db6183f8c3ce5c91 /docker | |
| download | camagru-d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d.tar.gz camagru-d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d.zip | |
Initial project scaffold
Set up MVC architecture with front controller, router, autoloader,
database singleton, and Docker Compose stack (Nginx + PHP-FPM + MariaDB).
Includes DB schema, responsive layout, dev tooling (php-cs-fixer,
parallel-lint), and documentation.
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/mariadb/init.sql | 39 | ||||
| -rw-r--r-- | docker/nginx/Dockerfile | 2 | ||||
| -rw-r--r-- | docker/nginx/default.conf | 21 | ||||
| -rw-r--r-- | docker/php/Dockerfile | 15 |
4 files changed, 77 insertions, 0 deletions
diff --git a/docker/mariadb/init.sql b/docker/mariadb/init.sql new file mode 100644 index 0000000..2cc0d6f --- /dev/null +++ b/docker/mariadb/init.sql @@ -0,0 +1,39 @@ +CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) UNIQUE NOT NULL, + email VARCHAR(255) UNIQUE NOT NULL, + password_hash VARCHAR(255) NOT NULL, + is_verified BOOLEAN DEFAULT FALSE, + verification_token VARCHAR(64), + reset_token VARCHAR(64), + reset_token_expires DATETIME, + notify_comments BOOLEAN DEFAULT TRUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS posts ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + image_path VARCHAR(255) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS likes ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + post_id INT NOT NULL, + UNIQUE KEY unique_like (user_id, post_id), + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS comments ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + post_id INT NOT NULL, + content TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE +); diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..7ab8af1 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:1.27-alpine +COPY default.conf /etc/nginx/conf.d/default.conf diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..8a1bcc6 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + root /var/www/html/public; + index index.php; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_pass php:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\. { + deny all; + } +} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..8626073 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.5.4-fpm + +# Install system libs for GD (PNG + JPEG) and a mail agent, then compile PHP extensions +RUN apt-get update && apt-get install -y \ + libpng-dev \ + libjpeg62-turbo-dev \ + msmtp \ + && docker-php-ext-configure gd --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd pdo_mysql \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "upload_max_filesize = 10M" > /usr/local/etc/php/conf.d/uploads.ini \ + && echo "post_max_size = 10M" >> /usr/local/etc/php/conf.d/uploads.ini + +WORKDIR /var/www/html |
