Docker Image #4

Merged
skobkin merged 5 commits from feature_docker_image into master 2022-07-08 02:24:29 +00:00
13 changed files with 358 additions and 397 deletions

40
.dockerignore Normal file
View file

@ -0,0 +1,40 @@
### Symfony template
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
# Cache, session files and logs (Symfony3)
/var/cache/*
/var/sessions/*
!var/cache/.gitkeep
!var/sessions/.gitkeep
# Logs (Symfony4)
/var/log/*
!var/log/.gitkeep
# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Composer PHAR
/composer.phar
# Backup entities generated with doctrine:generate:entities command
**/Entity/*~
# Embedded web-server pid file
/.web-server-pid
# DotEnv
.env.local

2
.env
View file

@ -3,7 +3,7 @@
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ### ###> symfony/framework-bundle ###
APP_ENV=dev APP_ENV=prod
APP_SECRET=xxx APP_SECRET=xxx
###< symfony/framework-bundle ### ###< symfony/framework-bundle ###

5
.gitignore vendored
View file

@ -9,11 +9,6 @@
/var/ /var/
/vendor/ /vendor/
###< symfony/framework-bundle ### ###< symfony/framework-bundle ###
###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
###> baldinof/roadrunner-bundle ### ###> baldinof/roadrunner-bundle ###
/bin/rr /bin/rr
###< baldinof/roadrunner-bundle ### ###< baldinof/roadrunner-bundle ###

View file

@ -1,12 +1,11 @@
# https://roadrunner.dev/docs/intro-config/2.x/en
version: "2.7" version: "2.7"
server: server:
command: "php public/index.php" command: "php public/index.php"
# If you are not using symfony 5.3+ and the new Runtime component:
# remove the previous `command` line above and uncomment the line below to use the deprecated command.
# command: "php bin/console baldinof:roadrunner:worker"
env: env:
- APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime
- APP_ENV: prod
http: http:
address: 0.0.0.0:8080 address: 0.0.0.0:8080
@ -16,6 +15,10 @@ http:
static: static:
dir: "public" dir: "public"
forbid: [ ".php", ".htaccess" ] forbid: [ ".php", ".htaccess" ]
pool:
max_jobs: 16
supervisor:
max_worker_memory: 256
logs: logs:
mode: production mode: production

39
Dockerfile Normal file
View file

@ -0,0 +1,39 @@
# https://github.com/roadrunner-server/roadrunner/pkgs/container/roadrunner
FROM ghcr.io/roadrunner-server/roadrunner:latest AS roadrunner
FROM php:8.1-alpine
ENV PHP_TIMEZONE Europe/Moscow
ENV APP_ENV=prod
WORKDIR /app
COPY --from=roadrunner /usr/bin/rr /app/bin/rr
COPY . /app/
RUN apk update && \
apk add autoconf build-base icu libpq postgresql-dev && \
docker-php-ext-configure intl && \
docker-php-ext-configure pdo_pgsql && \
docker-php-ext-configure sockets && \
docker-php-ext-install -j$(nproc) intl && \
docker-php-ext-install -j$(nproc) pdo_pgsql && \
docker-php-ext-install -j$(nproc) sockets && \
pecl install igbinary-3.2.7 && \
pecl install redis-5.3.7 && \
docker-php-ext-enable igbinary && \
docker-php-ext-enable intl && \
docker-php-ext-enable pdo_pgsql && \
docker-php-ext-enable redis && \
apk del autoconf build-base postgresql-dev && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
echo "date.timezone = $PHP_TIMEZONE" > $PHP_INI_DIR/conf.d/timezone.ini && \
mkdir -p /usr/local/bin && \
wget -O /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar && \
chmod +x /usr/local/bin/composer && \
ls -la /app && ls -la /app/bin && \
chmod +x /app/bin/console && \
/usr/local/bin/composer install --no-dev --no-progress --no-interaction --optimize-autoloader
VOLUME /var/log
CMD ["/app/bin/rr", "serve"]

View file

@ -91,3 +91,24 @@ php bin/console user:add <your_username> <your_email> [your_password] [--invites
# see --help for more info # see --help for more info
php bin/console invite:add <username> <number-of-invites> php bin/console invite:add <username> <number-of-invites>
``` ```
## Enabling dev mode
```shell
echo 'APP_ENV=dev > .env.local'
```
## Running in [RoadRunner](https://roadrunner.dev)
```shell
# First time only:
./vendor/bin/rr get --location bin/
# Running the server:
./bin/rr serve
# Running the server in dev mode (watching enabled)
bin/rr serve -c .rr.dev.yaml
```
Read more [here](https://github.com/baldinof/roadrunner-bundle) and [here](https://github.com/roadrunner-server/roadrunner).

View file

@ -53,8 +53,7 @@
"symfony/yaml": "^5.4" "symfony/yaml": "^5.4"
}, },
"require-dev": { "require-dev": {
"symfony/web-profiler-bundle": "^5.4", "symfony/web-profiler-bundle": "^5.4"
"symfony/web-server-bundle": "^4.1"
}, },
"config": { "config": {
"preferred-install": { "preferred-install": {
@ -100,7 +99,8 @@
}, },
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": false "allow-contrib": false,
"require": "5.4.*"
} }
} }
} }

590
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,11 @@
<?php <?php
declare(strict_types=1);
return [ return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],

View file

@ -3,7 +3,8 @@ baldinof_road_runner:
# See https://github.com/baldinof/roadrunner-bundle#kernel-reboots # See https://github.com/baldinof/roadrunner-bundle#kernel-reboots
kernel_reboot: kernel_reboot:
# if you want to use a fresh container on each request, use the `always` strategy # if you want to use a fresh container on each request, use the `always` strategy
strategy: on_exception #strategy: on_exception
strategy: always
# Exceptions you KNOW that do not put your app in an errored state # Exceptions you KNOW that do not put your app in an errored state
allowed_exceptions: allowed_exceptions:
- Symfony\Component\HttpKernel\Exception\HttpExceptionInterface - Symfony\Component\HttpKernel\Exception\HttpExceptionInterface

View file

@ -2,16 +2,19 @@ version: '3.7'
services: services:
magnetico-web: magnetico-web:
image: skobkin/magnetico-web-fpm image: skobkin/magnetico-web
build: build:
context: ./docker context: .
container_name: magnetico-web-fpm container_name: magnetico-web
network_mode: host hostname: magnetico-web
extra_hosts:
- 'host.docker.internal:host-gateway'
ports: ports:
- "127.0.0.1:${PHP_FPM_PORT:-9000}:9000/tcp" - "127.0.0.1:${EXT_HTTP_PORT:-8080}:8080/tcp"
restart: unless-stopped restart: unless-stopped
user: "$UID"
volumes: volumes:
- "${APP_LOCAL_PATH}:${APP_LOCAL_PATH}" - "${LOG_PATH:-./var/log}:/app/var/log"
logging: logging:
driver: "json-file" driver: "json-file"
options: options:

View file

@ -1,11 +0,0 @@
FROM php:7.4-fpm-alpine
ENV PHP_TIMEZONE Europe/Moscow
RUN apk update && \
apk add postgresql-dev libpq && \
docker-php-ext-configure pdo_pgsql && \
docker-php-ext-install -j$(nproc) pdo_pgsql && \
apk del postgresql-dev && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
echo "date.timezone = $PHP_TIMEZONE" > $PHP_INI_DIR/conf.d/timezone.ini

View file

@ -370,9 +370,6 @@
"symfony/polyfill-uuid": { "symfony/polyfill-uuid": {
"version": "v1.13.1" "version": "v1.13.1"
}, },
"symfony/process": {
"version": "v4.1.0"
},
"symfony/property-access": { "symfony/property-access": {
"version": "v4.1.0" "version": "v4.1.0"
}, },
@ -475,15 +472,6 @@
"ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6" "ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6"
} }
}, },
"symfony/web-server-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "dae9b39fd6717970be7601101ce5aa960bf53d9a"
}
},
"symfony/yaml": { "symfony/yaml": {
"version": "v4.1.0" "version": "v4.1.0"
}, },