diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/config.yml rename to .github/ISSUE_TEMPLATE/config.yml diff --git a/Makefile b/Makefile index a1f253a..f48b8bc 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,13 @@ test-unit: vendor/bin/phpunit --testsuite unit_tests --display-warnings test-integration: - vendor/bin/phpunit --testsuite integration_tests --display-warnings \ No newline at end of file + vendor/bin/phpunit --testsuite integration_tests --display-warnings + + +# docker file + +docker-up: + docker compose up --build -d + +docker-down: + docker compose down --remove-orphans \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ada4115 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,25 @@ +services: + php-fpm: + build: + context: ./docker/php-fpm + volumes: + - ./:/var/www/bitrix24-php-lib + nginx: + build: + context: ./docker/nginx + volumes: + - ./:/var/www/bitrix24-php-lib + ports: + - "8081:80" + depends_on: + - php-fpm + postgres-container: + image: postgres + build: + context: ./docker/postgres + ports: + - "5432:5432" + volumes: + - ./docker/postgres/data:/var/lib/postgresql/data + restart: always + diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..922b636 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx:1.27-alpine + +RUN rm /etc/nginx/conf.d/default.conf + +COPY ./conf.d/nginx.conf /etc/nginx/conf.d/ \ No newline at end of file diff --git a/docker/nginx/conf.d/nginx.conf b/docker/nginx/conf.d/nginx.conf new file mode 100644 index 0000000..7ef599a --- /dev/null +++ b/docker/nginx/conf.d/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name localhost; + + root /var/www/bitrix24-php-lib; + index index.html index.htm index.php; + + # Redirects requests to index.php if the file is not found + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + # Passes PHP requests to PHP-FPM container + location ~ \.php$ { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_pass php-fpm:9000; # Replace with your PHP-FPM container name + fastcgi_index index.php; + } +} \ No newline at end of file diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile new file mode 100644 index 0000000..67daccf --- /dev/null +++ b/docker/php-fpm/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.2-fpm-alpine + +RUN set -ex \ + && apk --no-cache add \ + postgresql-dev \ + oniguruma-dev \ + libzip-dev \ + curl-dev \ + && docker-php-ext-install pdo pdo_pgsql mbstring zip curl bcmath + +WORKDIR /bitrix24-php-lib + +COPY ./ ./ \ No newline at end of file diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile new file mode 100644 index 0000000..8d7a370 --- /dev/null +++ b/docker/postgres/Dockerfile @@ -0,0 +1,12 @@ +FROM postgres:16.4-alpine + +# Устанавливаем переменные окружения для настройки базы данных +ENV POSTGRES_USER=kirill +ENV POSTGRES_PASSWORD=bitrix24lib +ENV POSTGRES_DB=bitrixAppDb + +# Копируем SQL-скрипты для инициализации базы данных (если есть) +# COPY init.sql /docker-entrypoint-initdb.d/ + +# Открываем порт PostgreSQL +EXPOSE 5432 \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..b70805a --- /dev/null +++ b/index.php @@ -0,0 +1,17 @@ +"; +$conn_string = "pgsql:host=localhost;port=5432;dbname=bitrixAppDb;user=kirill;password=bitrix24lib"; +try { + $db = new PDO($conn_string); + + // Установка режима обработки ошибок + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + echo "Подключение к базе данных успешно установлено."; +}catch (PDOException $error) +{ + echo "Ошибка :". $error->getMessage(); +} + +?>