From 85749d2e89062489679403c896f55991ed74bb01 Mon Sep 17 00:00:00 2001
From: "Alex. Plokhikh" <a.plohih@iqdev.digital>
Date: Wed, 17 Apr 2024 15:23:29 +0500
Subject: [PATCH] STA-931| add nginx, docker compose, postgres

---
 Dockerfile            |  3 ++-
 compose.override.yaml | 19 -------------------
 compose.yaml          | 26 --------------------------
 docker-compose.yml    | 37 +++++++++++++++++++++++++++++++++++++
 nginx/Dockerfile      |  5 +++++
 nginx/default.conf    | 16 ++++++++++++++++
 6 files changed, 60 insertions(+), 46 deletions(-)
 delete mode 100644 compose.override.yaml
 delete mode 100644 compose.yaml
 create mode 100644 docker-compose.yml
 create mode 100644 nginx/Dockerfile
 create mode 100644 nginx/default.conf

diff --git a/Dockerfile b/Dockerfile
index 026bdee..f269cee 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,4 +12,5 @@ ENV COMPOSER_ALLOW_SUPERUSER=1
 RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
 RUN composer install
 
-CMD ["php"]
\ No newline at end of file
+RUN php public/index.php
+CMD ["php-fpm"]
\ No newline at end of file
diff --git a/compose.override.yaml b/compose.override.yaml
deleted file mode 100644
index 4ddb3ff..0000000
--- a/compose.override.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-version: '3'
-
-services:
-###> doctrine/doctrine-bundle ###
-  database:
-    ports:
-      - "5432"
-###< doctrine/doctrine-bundle ###
-
-###> symfony/mailer ###
-  mailer:
-    image: axllent/mailpit
-    ports:
-      - "1025"
-      - "8025"
-    environment:
-      MP_SMTP_AUTH_ACCEPT_ANY: 1
-      MP_SMTP_AUTH_ALLOW_INSECURE: 1
-###< symfony/mailer ###
diff --git a/compose.yaml b/compose.yaml
deleted file mode 100644
index dd791d9..0000000
--- a/compose.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-version: '3'
-
-services:
-###> doctrine/doctrine-bundle ###
-  database:
-    image: postgres:${POSTGRES_VERSION:-16}-alpine
-    environment:
-      POSTGRES_DB: ${POSTGRES_DB:-app}
-      # You should definitely change the password in production
-      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
-      POSTGRES_USER: ${POSTGRES_USER:-app}
-    healthcheck:
-      test: ["CMD", "pg_isready"]
-      timeout: 5s
-      retries: 5
-      start_period: 60s
-    volumes:
-      - database_data:/var/lib/postgresql/data:rw
-      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
-      # - ./docker/db/data:/var/lib/postgresql/data:rw
-###< doctrine/doctrine-bundle ###
-
-volumes:
-###> doctrine/doctrine-bundle ###
-  database_data:
-###< doctrine/doctrine-bundle ###
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..1230181
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,37 @@
+version: '3.1'
+
+services:
+  db:
+    image: postgres:16.2
+    environment:
+      POSTGRES_PASSWORD: 'root'
+      POSTGRES_USER: 'root'
+    networks:
+      - app
+    ports:
+      - '5432:5432'
+
+  nginx:
+    build:
+      dockerfile: nginx/Dockerfile
+    ports:
+      - '80:80'
+      - '433:433'
+    networks:
+      - app
+    links:
+      - app
+    depends_on:
+      - app
+
+  app:
+    build:
+      dockerfile: Dockerfile
+    networks:
+      - app
+    depends_on:
+      - db
+
+networks:
+  app:
+    driver: bridge
\ No newline at end of file
diff --git a/nginx/Dockerfile b/nginx/Dockerfile
new file mode 100644
index 0000000..dbbf268
--- /dev/null
+++ b/nginx/Dockerfile
@@ -0,0 +1,5 @@
+FROM nginx:alpine
+
+COPY ../. app
+
+ADD nginx/default.conf /etc/nginx/conf.d/
\ No newline at end of file
diff --git a/nginx/default.conf b/nginx/default.conf
new file mode 100644
index 0000000..3df54dd
--- /dev/null
+++ b/nginx/default.conf
@@ -0,0 +1,16 @@
+server {
+    index index.php;
+    error_log  /var/log/nginx/error.log;
+    access_log /var/log/nginx/access.log;
+    root /app/public;
+
+    location ~ \.php$ {
+        try_files $uri =404;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass app:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+    }
+}
-- 
GitLab