From 70376a8b059d115e359a80b1732efd7f42c5790b Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Mon, 22 Apr 2024 14:18:47 +0500 Subject: [PATCH 1/6] =?UTF-8?q?STA-929=20|=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20nginx=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 +++ docker-compose.yaml | 44 +++++++++++++++++++++++++++++++++++++ docker/nginx/Dockerfile | 6 +++++ docker/nginx/default.conf | 31 ++++++++++++++++++++++++++ docker/{ => php}/Dockerfile | 12 ++++++---- 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yaml create mode 100644 docker/nginx/Dockerfile create mode 100644 docker/nginx/default.conf rename docker/{ => php}/Dockerfile (61%) diff --git a/.env b/.env index a7ae4fc..416d31f 100644 --- a/.env +++ b/.env @@ -39,3 +39,6 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 ###> symfony/mailer ### # MAILER_DSN=null://null ###< symfony/mailer ### +DATABASE_PORT="5432" +NGINX_PORT="80" +APP_BASE_DIR="./" diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9a33442 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,44 @@ +version: "3" + +services: + database: + container_name: postgres + image: postgres:16.2-alpine + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: 12345 + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - "${DATABASE_PORT}:${DATABASE_PORT}" + networks: + - internal + nginx: + build: + dockerfile: ./docker/nginx/Dockerfile + args: + COMPOSER_AUTH: "{}" + APP_BASE_DIR: ${APP_BASE_DIR-.} + volumes: + - ".:/app" + - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf' + ports: + - '${NGINX_PORT}:${NGINX_PORT}' + networks: + - internal + app: + build: + dockerfile: ./docker/php/Dockerfile + args: + COMPOSER_AUTH: "{}" + APP_BASE_DIR: ${APP_BASE_DIR-.} + volumes: + - ".:/app" + ports: + - "9000:9000" + restart: unless-stopped + networks: + - internal + +networks: + internal: + driver: bridge \ No newline at end of file diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..4ea2c80 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:alpine + +WORKDIR "/app" + +ARG APP_BASE_DIR +COPY $APP_BASE_DIR . diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..e282987 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,31 @@ +server { + #This config is based on https://github.com/daylerees/laravel-website-configs/blob/6db24701073dbe34d2d58fea3a3c6b3c0cd5685b/nginx.conf + + # The location of our project's public directory. + root /app/public; + + # Point index to the Laravel front controller. + index index.php; + + location / { + # URLs to attempt, including pretty ones. + try_files $uri $uri/ /index.php?$query_string; + } + + # Remove trailing slash to please routing system. + if (!-d $request_filename) { + rewrite ^/(.+)/$ /$1 permanent; + } + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini + # # With php5-fpm: + 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; + } +} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/php/Dockerfile similarity index 61% rename from docker/Dockerfile rename to docker/php/Dockerfile index 2fca0d5..e4b730f 100644 --- a/docker/Dockerfile +++ b/docker/php/Dockerfile @@ -2,11 +2,13 @@ FROM php:fpm-alpine WORKDIR "/app" -COPY .. . +ARG APP_BASE_DIR +COPY $APP_BASE_DIR . + +RUN apk update && \ + apk add libpq-dev && \ + docker-php-ext-install pdo pdo_pgsql pgsql -RUN set -ex \ - && apk --no-cache add \ - postgresql-dev RUN docker-php-ext-install pdo pdo_pgsql @@ -16,4 +18,6 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local RUN composer install +RUN chmod -R 777 /app/var + CMD ["php-fpm"] -- GitLab From 52dd4b70cc1648316872b63ca7dcece58b6427a6 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Wed, 24 Apr 2024 17:31:17 +0500 Subject: [PATCH 2/6] =?UTF-8?q?STA-930=20|=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 ++ .gitignore | 4 +++- docker-compose.yaml | 6 ++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 416d31f..c55fbe3 100644 --- a/.env +++ b/.env @@ -42,3 +42,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 DATABASE_PORT="5432" NGINX_PORT="80" APP_BASE_DIR="./" +POSTGRES_USER="postgres" +POSTGRES_PASSWORD="12345" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 930e1e2..6dd4647 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ /public/assets/ /assets/vendor/ ###< symfony/asset-mapper ### -/.idea \ No newline at end of file +/.idea +.env; +.env.test; \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 9a33442..b41d486 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,8 +5,8 @@ services: container_name: postgres image: postgres:16.2-alpine environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: 12345 + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_HOST_AUTH_METHOD: trust ports: - "${DATABASE_PORT}:${DATABASE_PORT}" @@ -33,8 +33,6 @@ services: APP_BASE_DIR: ${APP_BASE_DIR-.} volumes: - ".:/app" - ports: - - "9000:9000" restart: unless-stopped networks: - internal -- GitLab From 579a2d863925b9abc648c7becdbc7b7f25fc57b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=BB=D0=B0=D0=BD=20=D0=A8=D0=B0=D0=BC=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2?= Date: Wed, 24 Apr 2024 12:34:11 +0000 Subject: [PATCH 3/6] Delete .env --- .env | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index c55fbe3..0000000 --- a/.env +++ /dev/null @@ -1,46 +0,0 @@ -# In all environments, the following files are loaded if they exist, -# the latter taking precedence over the former: -# -# * .env contains default values for the environment variables needed by the app -# * .env.local uncommitted file with local overrides -# * .env.$APP_ENV committed environment-specific defaults -# * .env.$APP_ENV.local uncommitted environment-specific overrides -# -# Real environment variables win over .env files. -# -# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. -# https://symfony.com/doc/current/configuration/secrets.html -# -# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). -# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration - -###> symfony/framework-bundle ### -APP_ENV=dev -APP_SECRET=ea3ebbf899855d483050e0d1aad6a759 -###< symfony/framework-bundle ### - -###> doctrine/doctrine-bundle ### -# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml -# -# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" -# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" -###< doctrine/doctrine-bundle ### - -###> symfony/messenger ### -# Choose one of the transports below -# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages -# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages -MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 -###< symfony/messenger ### - -###> symfony/mailer ### -# MAILER_DSN=null://null -###< symfony/mailer ### -DATABASE_PORT="5432" -NGINX_PORT="80" -APP_BASE_DIR="./" -POSTGRES_USER="postgres" -POSTGRES_PASSWORD="12345" \ No newline at end of file -- GitLab From 2d7f28c72112aee8aac37cf6357e81e7962eb503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=BB=D0=B0=D0=BD=20=D0=A8=D0=B0=D0=BC=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2?= Date: Wed, 24 Apr 2024 12:34:45 +0000 Subject: [PATCH 4/6] Delete .env.test --- .env.test | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .env.test diff --git a/.env.test b/.env.test deleted file mode 100644 index 9e7162f..0000000 --- a/.env.test +++ /dev/null @@ -1,6 +0,0 @@ -# define your env variables for the test env here -KERNEL_CLASS='App\Kernel' -APP_SECRET='$ecretf0rt3st' -SYMFONY_DEPRECATIONS_HELPER=999999 -PANTHER_APP_ENV=panther -PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots -- GitLab From 3e2122dbbcd21ab56525d1834ff629b692ebce3e Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Wed, 24 Apr 2024 17:36:08 +0500 Subject: [PATCH 5/6] =?UTF-8?q?STA-930=20|=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6dd4647..f8810d3 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,5 @@ /assets/vendor/ ###< symfony/asset-mapper ### /.idea -.env; -.env.test; \ No newline at end of file +.env +.env.test \ No newline at end of file -- GitLab From bdf44fdf84cbdf49270e442904f275811b7ec641 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Thu, 2 May 2024 11:54:21 +0500 Subject: [PATCH 6/6] =?UTF-8?q?STA-930=20|=20=D0=9F=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D1=8E=20nginx=20=D0=B2=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 5 ++--- docker/nginx/Dockerfile | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b41d486..a4e3a36 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,7 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_HOST_AUTH_METHOD: trust ports: - - "${DATABASE_PORT}:${DATABASE_PORT}" + - "${DATABASE_PORT}:5432" networks: - internal nginx: @@ -20,9 +20,8 @@ services: APP_BASE_DIR: ${APP_BASE_DIR-.} volumes: - ".:/app" - - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf' ports: - - '${NGINX_PORT}:${NGINX_PORT}' + - '${NGINX_PORT}:80' networks: - internal app: diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 4ea2c80..085ae36 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -4,3 +4,4 @@ WORKDIR "/app" ARG APP_BASE_DIR COPY $APP_BASE_DIR . +RUN cp docker/nginx/default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file -- GitLab