Docker app.dockerfile
Опис:
app.dockerfile
FROM php:8.2-fpm-alpine
WORKDIR /var/www/app
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER 1
ARG PHP_EXTENSIONS="zip intl mysqli pdo_mysql opcache bcmath mbstring exif pcntl sysvmsg sysvsem sysvshm"
ARG user
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
build-base \
g++ \
make \
automake \
autoconf \
libzip-dev \
icu-dev \
icu-libs \
zlib-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma-dev \
&& apk add --update \
bash \
git \
wget \
curl \
icu \
icu-data-full \
freetype-dev \
libzip \
libpng \
libjpeg-turbo \
freetype \
&& docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install $PHP_EXTENSIONS \
&& pecl install redis && docker-php-ext-enable redis.so \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
&& apk del .build-deps \
&& rm -rf /tmp/* /var/cache/apk/*
RUN adduser -S $user
USER $user
WORKDIR /var/www/app
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER 1
ARG PHP_EXTENSIONS="zip intl mysqli pdo_mysql opcache bcmath mbstring exif pcntl sysvmsg sysvsem sysvshm"
ARG user
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
build-base \
g++ \
make \
automake \
autoconf \
libzip-dev \
icu-dev \
icu-libs \
zlib-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma-dev \
&& apk add --update \
bash \
git \
wget \
curl \
icu \
icu-data-full \
freetype-dev \
libzip \
libpng \
libjpeg-turbo \
freetype \
&& docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install $PHP_EXTENSIONS \
&& pecl install redis && docker-php-ext-enable redis.so \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
&& apk del .build-deps \
&& rm -rf /tmp/* /var/cache/apk/*
RUN adduser -S $user
USER $user
nginx - default.conf
server {
listen 4343;
index index.php;
error_log /var/log/nginx/error.log;
access_log off;
root /var/www/app/public;
location /horizon {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php: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;
}
}
listen 4343;
index index.php;
error_log /var/log/nginx/error.log;
access_log off;
root /var/www/app/public;
location /horizon {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php: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;
}
}
docker-compose.yml
version: '3.8'
networks:
api-network-bee:
driver: bridge
volumes:
api-bee-redis:
api-bee-mysql:
services:
redis:
image: redis:alpine
command: [ "redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD:-123321}" ]
container_name: redis-api-bee
ports:
- ${REDIS_PORT:-6379}:6379
volumes:
- api-bee-redis:/data:delegated
restart: unless-stopped
networks:
- api-network-bee
mysql:
image: mysql:8.0.32
container_name: mysql-api-bee
restart: unless-stopped
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- api-bee-mysql:/var/lib/mysql:delegated
ports:
- 3306:${DB_PORT:-3306}
networks:
- api-network-bee
nginx:
container_name: nginx-api-bee
image: nginx:alpine
depends_on:
- php
restart: unless-stopped
ports:
- ${NGINX_PORT:-4343}:${NGINX_PORT:-4343}
volumes:
- $PWD/docker/local/nginx/conf.d/:/etc/nginx/conf.d/
- $PWD/:/var/www/app
networks:
- api-network-bee
php:
container_name: app-api-bee
build:
context: .
dockerfile: $PWD/docker/local/app/app.dockerfile
args:
user: ${DEFAULT_USER:-admin}
depends_on:
- mysql
- redis
volumes:
- $PWD/:/var/www/app
restart: unless-stopped
networks:
- api-network-bee
adminer:
image: adminer
container_name: adminer-api-bee
ports:
- "8080:8080"
depends_on:
- mysql
restart: unless-stopped
networks:
- api-network-bee
networks:
api-network-bee:
driver: bridge
volumes:
api-bee-redis:
api-bee-mysql:
services:
redis:
image: redis:alpine
command: [ "redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD:-123321}" ]
container_name: redis-api-bee
ports:
- ${REDIS_PORT:-6379}:6379
volumes:
- api-bee-redis:/data:delegated
restart: unless-stopped
networks:
- api-network-bee
mysql:
image: mysql:8.0.32
container_name: mysql-api-bee
restart: unless-stopped
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- api-bee-mysql:/var/lib/mysql:delegated
ports:
- 3306:${DB_PORT:-3306}
networks:
- api-network-bee
nginx:
container_name: nginx-api-bee
image: nginx:alpine
depends_on:
- php
restart: unless-stopped
ports:
- ${NGINX_PORT:-4343}:${NGINX_PORT:-4343}
volumes:
- $PWD/docker/local/nginx/conf.d/:/etc/nginx/conf.d/
- $PWD/:/var/www/app
networks:
- api-network-bee
php:
container_name: app-api-bee
build:
context: .
dockerfile: $PWD/docker/local/app/app.dockerfile
args:
user: ${DEFAULT_USER:-admin}
depends_on:
- mysql
- redis
volumes:
- $PWD/:/var/www/app
restart: unless-stopped
networks:
- api-network-bee
adminer:
image: adminer
container_name: adminer-api-bee
ports:
- "8080:8080"
depends_on:
- mysql
restart: unless-stopped
networks:
- api-network-bee
Makefile
up:
- docker compose -f docker-compose.yml up -d
build:
- docker compose -f docker-compose.yml up --build -d
- docker compose -f docker-compose.yml up -d
build:
- docker compose -f docker-compose.yml up --build -d