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

hw1 #543

Open
wants to merge 3 commits into
base: SChernomordov/main
Choose a base branch
from
Open

hw1 #543

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
11 changes: 11 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# MySQL settings
MYSQL_DATABASE = sitemanager
Copy link

Choose a reason for hiding this comment

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

Не стоит комитить .env файл. Вместо него надо создавать .env.example где описывать все переменные которые нужно установить. А .env файл должен быть добавлен в .gitignore

MYSQL_USER = sitemanager
MYSQL_PASSWORD = 123
MYSQL_ROOT_PASSWORD = 123

# Site path
SITE_PATH=~/otus/hw1/www/

# ADD PROJECT NAME HERE
COMPOSE_PROJECT_NAME = otus
70 changes: 70 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: '3'

services:
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
image: nginx
container_name: nginx
ports:
- "80:80"
volumes:
- ${SITE_PATH}:/data/mysite.local
- php-fpm-socket:/var/run/d-socket
networks:
- app-network

php-fpm:
build:
context: ./php-fpm
dockerfile: Dockerfile
image: php-fpm
container_name: php-fpm
volumes:
- ${SITE_PATH}:/data/mysite.local
- php-fpm-socket:/var/run/d-socket
networks:
- app-network

redis:
image: redis:latest
container_name: redis
ports:
- "6379:6379"
volumes:
- ./var/redis/data:/data/mysite.local/redis
networks:
- app-network

memcached:
image: memcached:latest
container_name: memcached
volumes:
- ./var/memcached/data:/data/mysite.local/memcached
networks:
- app-network

mysql:
image: mysql:latest
container_name: mysql
restart: always
environment:
MYSQL_DATABASE: ${MYSQL_DB}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "3306:3306"
volumes:
- ./var/mysql:/var/lib/mysql
networks:
- app-network


volumes:
php-fpm-socket:

networks:
app-network:
driver: bridge
11 changes: 11 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nginx:latest

COPY ./conf/mysite.local.conf /etc/nginx/conf.d/mysite.local.conf

WORKDIR /data

VOLUME /data

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
28 changes: 28 additions & 0 deletions docker/nginx/conf/mysite.local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {

listen 80;

server_name mysite.local;

root /data/mysite.local;

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_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
30 changes: 30 additions & 0 deletions docker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:8.2-fpm

# ставим необходимые для нормальной работы модули
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libonig-dev \
libzip-dev \
libmemcached-dev \
zlib1g-dev libssl-dev \
&& 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 \
&& pecl install memcached \
&& docker-php-ext-enable memcached \
&& apt-get install -y libpq-dev \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql \
&& pecl install redis \
&& docker-php-ext-enable redis.so \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY ./php.ini /usr/local/etc/php/conf.d/php-custom.ini

WORKDIR /data/mysite.local

VOLUME /data

CMD ["php-fpm"]
2 changes: 2 additions & 0 deletions docker/php-fpm/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
session.save_handler = memcache
session.save_path = "tcp://memcache:11211"
7 changes: 7 additions & 0 deletions www/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

echo "Привет, Otus!<br>" . date("Y-m-d H:i:s") . "<br><br>";

echo "Что-то еще";

phpinfo();
Loading