Added docker-compose.yml

This commit is contained in:
Pijus Kamandulis 2023-09-13 00:02:07 +03:00
parent 9a979592e1
commit 5ad55753cf
5 changed files with 91 additions and 29 deletions

View File

@ -1,14 +1,14 @@
<?php
function GetConnectionToDB(){
//========SQL_CONFIG========//
$SQL_Host = "localhost";
$SQL_Database = "palm-paste";
$SQL_User = "paste";
$SQL_Password = "ckQgRJRhib74XMgVpzmn38uj1MrCcNnK7L9bc7zu";
$SQL_Host = getenv('SQL_HOST') ?: "localhost";
$SQL_Database = getenv('SQL_DB') ?: "palm-paste";
$SQL_User = getenv('SQL_USER') ?: "paste";
$SQL_Password = getenv('SQL_PASS') ?: "ckQgRJRhib74XMgVpzmn38uj1MrCcNnK7L9bc7zu";
//========CONNECTION========//
$conn = new PDO('mysql:host='.$SQL_Host.';dbname='.$SQL_Database.';charset=utf8mb4', $SQL_User, $SQL_Password);
return $conn;
}
//========CRON_JOBS=========//
$CRON_ExpireKey = "b1g51bf6g";
$CRON_ExpireKey = getenv('CRON_EXPIREKEY') ?: "b1g51bf6g";
?>

42
docker-compose.yml Normal file
View File

@ -0,0 +1,42 @@
version: '3.9'
services:
web:
image: nginx:latest
ports:
- '8080:80'
volumes:
- ./:/var/www/html
- ./nginx_cfg.conf:/etc/nginx/conf.d/default.conf
links:
- php-fpm
php-fpm:
build:
dockerfile: "php-fmt.Dockerfile"
environment:
SQL_HOST: db
volumes:
- ./:/var/www/html
db:
image: mysql:5.6
container_name: db
environment:
MYSQL_ROOT_PASSWORD: 1asd6ad151g16hj161m6u16m1ik187u1y6m1
MYSQL_DATABASE: palm-paste
MYSQL_USER: paste
MYSQL_PASSWORD: ckQgRJRhib74XMgVpzmn38uj1MrCcNnK7L9bc7zu
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: pma
links:
- db
environment:
PMA_HOST: db
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80

32
nginx_cfg.conf Normal file
View File

@ -0,0 +1,32 @@
server {
index index.php index.html;
server_name phpfpm.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
if ( $uri !~ ^/(index\.php|css|js|robots\.txt|favicon\.ico|$) ) {
rewrite ^/u/(.*)$ /index.php?user=$1? last;
rewrite ^/delete/(.*)$ /delete.php?id=$1? last;
rewrite ^/([^/]+)/(.*)$ /index.php?page=$1&id=$2? last;
rewrite ^/(.*)$ /index.php?page=$1? last;
}
if ( $uri ~* ^/u/(css|js) ) {
rewrite ^/u/(.*)$ /u/$1? last;
}
if ( $uri ~* ^/delete/(css|js) ) {
rewrite ^/delete/(.*)$ /delete/$1? last;
}
}
}

View File

@ -1,15 +0,0 @@
# replace all occurrences of "paste" with the root of your palm-paste installation
location /paste {
if ( $uri !~ ^/paste/(index\.php|css|js|robots\.txt|favicon\.ico|$) ) {
rewrite ^/paste/u/(.*)$ /paste/index.php?user=$1? last;
rewrite ^/paste/delete/(.*)$ /paste/delete.php?id=$1? last;
rewrite ^/paste/([^/]+)/(.*)$ /paste/index.php?page=$1&id=$2? last;
rewrite ^/paste/(.*)$ /paste/index.php?page=$1? last;
}
if ( $uri ~* ^/paste/u/(css|js) ) {
rewrite ^/paste/u/(.*)$ /paste/u/$1? last;
}
if ( $uri ~* ^/paste/delete/(css|js) ) {
rewrite ^/paste/delete/(.*)$ /paste/delete/$1? last;
}
}

3
php-fmt.Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM php:fpm-alpine
RUN docker-php-ext-install pdo_mysql