diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..2e5aaeb04 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +init: docker-down docker-build docker-up + +docker-down: + docker compose down --remove-orphans + +docker-build: + docker compose build + +docker-up: + docker compose up -d diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..70687965b --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "alexander-pogorelov/date-time-helper": "^1.0" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 000000000..82cf5aa69 --- /dev/null +++ b/composer.lock @@ -0,0 +1,49 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "37fe2b892693f0bb43f94c7cbd003685", + "packages": [ + { + "name": "alexander-pogorelov/date-time-helper", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/alexander-pogorelov/date-time-helper.git", + "reference": "62cda91799e8675667a5cc32b94ad1855e093f8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alexander-pogorelov/date-time-helper/zipball/62cda91799e8675667a5cc32b94ad1855e093f8c", + "reference": "62cda91799e8675667a5cc32b94ad1855e093f8c", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlexanderPogorelov\\DateTimeHelper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "support": { + "issues": "https://github.com/alexander-pogorelov/date-time-helper/issues", + "source": "https://github.com/alexander-pogorelov/date-time-helper/tree/v1.1.0" + }, + "time": "2024-02-20T10:10:18+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..9c337f232 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,31 @@ +version: '3' + +services: + nginx: + image: nginx:latest + container_name: mysite-nginx + depends_on: + - php-fpm + ports: + - "80:80" + volumes: + - ./:/data/mysite.local + - ./nginx/hosts/mysite.local.conf:/etc/nginx/conf.d/mysite.local.conf + networks: + - app-network + + php-fpm: + build: + context: ./fpm + dockerfile: Dockerfile + image: mysite/php-fpm + container_name: mysite-php-fpm + working_dir: /data/mysite.local + volumes: + - ./:/data/mysite.local + networks: + - app-network + +networks: + app-network: + driver: bridge diff --git a/fpm/Dockerfile b/fpm/Dockerfile new file mode 100644 index 000000000..258acecbf --- /dev/null +++ b/fpm/Dockerfile @@ -0,0 +1,20 @@ +FROM php:8.2-fpm + +# ставим необходимые для нормальной работы модули +RUN apt-get update \ + && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libonig-dev \ + libzip-dev \ + libz-dev \ + libmcrypt-dev \ + && pecl install mcrypt-1.0.6 \ + && docker-php-ext-enable mcrypt \ + && docker-php-ext-install -j$(nproc) iconv mbstring mysqli pdo_mysql zip \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd + +# Устанавливаем Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/nginx/hosts/mysite.local.conf b/nginx/hosts/mysite.local.conf new file mode 100644 index 000000000..a9756bf2d --- /dev/null +++ b/nginx/hosts/mysite.local.conf @@ -0,0 +1,25 @@ +server { + listen 80; + server_name mysite.local; + root /data/mysite.local/public; + index index.php index.html; + + location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { + access_log off; + expires max; + } + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~* .php$ { + try_files $uri = 404; + fastcgi_split_path_info ^(.+.php)(/.+)$; + fastcgi_pass php-fpm:9000; + #fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/public/index.php b/public/index.php new file mode 100644 index 000000000..49c9198ad --- /dev/null +++ b/public/index.php @@ -0,0 +1,19 @@ +getCurrentDateMySQL($timezone); +$nowObject = $helper->createDateFromString($nowString, $timezone); + +echo "
"; +echo 'Current Date in MySQL format:' . PHP_EOL; +echo $nowString; +echo "";
"; +echo 'Current Date as DateTimeImmutable object:'; +print_r($nowObject); +echo "