Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker containers #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@ test-unit:
vendor/bin/phpunit --testsuite unit_tests --display-warnings

test-integration:
vendor/bin/phpunit --testsuite integration_tests --display-warnings
vendor/bin/phpunit --testsuite integration_tests --display-warnings


# docker file

docker-up:
docker compose up --build -d

docker-down:
docker compose down --remove-orphans
25 changes: 25 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
php-fpm:
build:
context: ./docker/php-fpm
volumes:
- ./:/var/www/bitrix24-php-lib
nginx:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KarlsonComplete зачем тебе nginx если ты гонишь все в CLI?

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

5 changes: 5 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
20 changes: 20 additions & 0 deletions docker/nginx/conf.d/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KarlsonComplete это из елисеева или примеров симфони?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У елисеева в первом видео было.

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;
}
}
13 changes: 13 additions & 0 deletions docker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:8.2-fpm-alpine
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а какие экстеншены ты по дефолту доставишь и включишь?


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 ./ ./
12 changes: 12 additions & 0 deletions docker/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM postgres:16.4-alpine

# Устанавливаем переменные окружения для настройки базы данных
ENV POSTGRES_USER=kirill
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

погугли что там по этому поводу находится, закинь сюда варианты.

Add CI step for monitoring leaked api-keys in codebase

Кажись вот тут ребята рассказывали
https://www.youtube.com/watch?v=YFWXV0YrDnE

ENV POSTGRES_PASSWORD=bitrix24lib
ENV POSTGRES_DB=bitrixAppDb

# Копируем SQL-скрипты для инициализации базы данных (если есть)
# COPY init.sql /docker-entrypoint-initdb.d/

# Открываем порт PostgreSQL
EXPOSE 5432
17 changes: 17 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
echo 'Hello123';
echo "<br>";
$conn_string = "pgsql:host=localhost;port=5432;dbname=bitrixAppDb;user=kirill;password=bitrix24lib";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

всё через переменные окружения

try {
$db = new PDO($conn_string);

// Установка режима обработки ошибок
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

echo "Подключение к базе данных успешно установлено.";
}catch (PDOException $error)
{
echo "Ошибка :". $error->getMessage();
}

?>
Loading