version: '3.9'
services:
www:
build: .
ports:
- "8099:80"
volumes:
- ./www:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql
ports:
- "3377:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: test
command: --sql_mode=
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- db:db
ports:
- 8899:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: root
volumes:
persistent:
-- Хост: localhost:3306
-- Время создания: Июн 07 2023 г., 19:44
-- Версия сервера: 5.7.42-cll-lve
-- Версия PHP: 8.1.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
version: "3.9"
services:
app:
build:
args:
user: user
uid: 1000
context: ./
dockerfile: Dockerfile
image: user
container_name: user-app
restart: unless-stopped
working_dir: /var/www/
volumes:
- ./:/var/www
networks:
- default
db:
image: mysql:8
container_name: user-db
restart: unless-stopped
environment:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: password
MYSQL_USER: user
volumes:
- ./docker-compose/mysql:/docker-entrypoint-initdb.d
networks:
- default
nginx:
image: nginx:alpine
container_name: user-nginx
restart: unless-stopped
ports:
- "80:80"
volumes:
- ./:/var/www
- ./docker-compose/nginx:/etc/nginx/conf.d
networks:
- default
phpmyadmin:
image: phpmyadmin
restart: unless-stopped
ports:
- 88:80
volumes:
- ./:/var/www/pma
environment:
- PMA_ARBITRARY=1
- PMA_USER=root
- PMA_PASSWORD=root
networks:
default:
driver: bridge
FROM php:8.2-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
libpq-dev
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd mysqli pgsql pdo_pgsql
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www
USER $user
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/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;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}