Skip to content

Commit be4370d

Browse files
init
0 parents  commit be4370d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6580
-0
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor
2+
var
3+
.git
4+
Makefile

.env

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
#
13+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
15+
16+
###> symfony/framework-bundle ###
17+
APP_ENV=dev
18+
APP_SECRET=2570182730eda74bfff1c16e54fd7fc1
19+
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
20+
#TRUSTED_HOSTS='^(localhost|example\.com)$'
21+
###< symfony/framework-bundle ###
22+
23+
###> doctrine/doctrine-bundle ###
24+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
25+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
26+
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
27+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
28+
DATABASE_URL=postgres://sf_user:random_password@postgres/test
29+
###< doctrine/doctrine-bundle ###

.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
###> symfony/framework-bundle ###
2+
/.env.local
3+
/.env.local.php
4+
/.env.*.local
5+
/config/secrets/prod/prod.decrypt.private.php
6+
/public/bundles/
7+
/src/.preload.php
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###
11+
12+
###> symfony/phpunit-bridge ###
13+
.phpunit
14+
.phpunit.result.cache
15+
/phpunit.xml
16+
###< symfony/phpunit-bridge ###
17+
18+
.idea

Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
ARG PHP_VERSION=7.4.10
2+
ARG NGINX_VERSION=1.18
3+
4+
FROM php:${PHP_VERSION}-fpm-alpine AS app_php
5+
6+
ARG WORKDIR=/app
7+
8+
RUN docker-php-source extract \
9+
&& apk add --update --virtual .build-deps autoconf g++ make pcre-dev icu-dev openssl-dev libxml2-dev libmcrypt-dev git libpng-dev \
10+
# Install pgsql goodness
11+
&& apk add postgresql-dev \
12+
&& docker-php-ext-install pgsql pdo_pgsql \
13+
&& apk del postgresql-libs libsasl db \
14+
# Instaling pecl modules
15+
&& pecl install apcu xdebug \
16+
# Enable pecl modules
17+
&& docker-php-ext-enable apcu opcache \
18+
# Installing intl
19+
&& apk add icu-libs icu \
20+
&& docker-php-ext-install intl \
21+
# Post run
22+
&& runDeps="$( \
23+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
24+
| tr ',' '\n' \
25+
| sort -u \
26+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
27+
)" \
28+
&& apk add --no-cache --virtual .app-phpexts-rundeps $runDeps \
29+
&& pecl clear-cache \
30+
&& docker-php-source delete \
31+
&& apk del --purge .build-deps \
32+
&& rm -rf /tmp/pear \
33+
&& rm -rf /var/cache/apk/*
34+
35+
COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer
36+
COPY docker/php/php.ini $PHP_INI_DIR/conf.d/php.ini
37+
COPY docker/php/php-cli.ini $PHP_INI_DIR/conf.d/php-cli.ini
38+
COPY docker/php/xdebug.ini $PHP_INI_DIR/conf.d/xdebug.ini
39+
40+
RUN mkdir -p ${WORKDIR}
41+
WORKDIR ${WORKDIR}
42+
43+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
44+
ENV COMPOSER_ALLOW_SUPERUSER=1
45+
RUN set -eux; \
46+
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
47+
composer clear-cache
48+
49+
# prevent the reinstallation of vendors at every changes in the source code
50+
COPY composer.json composer.lock symfony.lock ./
51+
RUN set -eux; \
52+
composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-suggest; \
53+
composer clear-cache
54+
55+
RUN set -eux \
56+
&& mkdir -p var/cache var/log \
57+
&& composer dump-autoload --classmap-authoritative
58+
59+
VOLUME ${WORKDIR}/var
60+
61+
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
62+
RUN chmod +x /usr/local/bin/docker-entrypoint
63+
64+
ENTRYPOINT ["docker-entrypoint"]
65+
CMD ["php-fpm"]
66+
67+
68+
FROM nginx:${NGINX_VERSION}-alpine AS app_nginx
69+
70+
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/
71+
72+
WORKDIR /app/public

Dockerfile_prod

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
ARG PHP_VERSION=7.4.10
2+
ARG NGINX_VERSION=1.18
3+
4+
FROM php:${PHP_VERSION}-fpm-alpine AS app_php
5+
6+
ARG WORKDIR=/app
7+
8+
RUN docker-php-source extract \
9+
&& apk add --update --virtual .build-deps autoconf g++ make pcre-dev icu-dev openssl-dev libxml2-dev libmcrypt-dev git libpng-dev \
10+
# Install pgsql goodness
11+
&& apk add postgresql-dev \
12+
&& docker-php-ext-install pgsql pdo_pgsql \
13+
&& apk del postgresql-libs libsasl db \
14+
# Instaling pecl modules
15+
&& pecl install apcu \
16+
# Enable pecl modules
17+
&& docker-php-ext-enable apcu opcache \
18+
# Installing intl
19+
&& apk add icu-libs icu \
20+
&& docker-php-ext-install intl \
21+
# Post run
22+
&& runDeps="$( \
23+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
24+
| tr ',' '\n' \
25+
| sort -u \
26+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
27+
)" \
28+
&& apk add --no-cache --virtual .app-phpexts-rundeps $runDeps \
29+
&& pecl clear-cache \
30+
&& docker-php-source delete \
31+
&& apk del --purge .build-deps \
32+
&& rm -rf /tmp/pear \
33+
&& rm -rf /var/cache/apk/*
34+
35+
COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer
36+
COPY docker/php/php.prod.ini $PHP_INI_DIR/conf.d/php.ini
37+
COPY docker/php/php-cli.prod.ini $PHP_INI_DIR/conf.d/php-cli.ini
38+
39+
RUN mkdir -p ${WORKDIR}
40+
WORKDIR ${WORKDIR}
41+
42+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
43+
ENV COMPOSER_ALLOW_SUPERUSER=1
44+
RUN set -eux; \
45+
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
46+
composer clear-cache
47+
48+
# prevent the reinstallation of vendors at every changes in the source code
49+
COPY composer.json composer.lock symfony.lock ./
50+
RUN set -eux; \
51+
composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-suggest; \
52+
composer clear-cache
53+
54+
COPY .env ./
55+
COPY bin bin/
56+
COPY config config/
57+
COPY src src/
58+
COPY public public/
59+
60+
RUN set -eux \
61+
&& mkdir -p var/cache var/log \
62+
&& composer dump-autoload --classmap-authoritative \
63+
&& APP_SECRET='' composer run-script post-install-cmd
64+
65+
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
66+
RUN chmod +x /usr/local/bin/docker-entrypoint
67+
68+
RUN chown www-data:www-data -R ${WORKDIR}/var/* ${WORKDIR}/vendor/*
69+
USER www-data
70+
71+
ENTRYPOINT ["docker-entrypoint"]
72+
CMD ["php-fpm"]
73+
74+
75+
FROM nginx:${NGINX_VERSION}-alpine AS app_nginx
76+
77+
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/
78+
79+
WORKDIR /app/public
80+
81+
COPY --from=app_php /app/public public/

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
up:
2+
docker-compose up -d
3+
4+
down:
5+
docker-compose down
6+
7+
rebuild:
8+
docker-compose down -v --remove-orphans
9+
docker-compose rm -vsf
10+
docker-compose up -d --build
11+
12+
db:
13+
docker-compose exec php ./bin/console doctrine:database:drop --force
14+
docker-compose exec php ./bin/console doctrine:database:create
15+
docker-compose exec php ./bin/console doctrine:migrations:migrate -n
16+
17+
prod:
18+
docker-compose -f docker-compose_prod.yml up -d
19+
20+
prod_build:
21+
docker-compose -f docker-compose_prod.yml build

bin/console

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\Dotenv\Dotenv;
8+
use Symfony\Component\ErrorHandler\Debug;
9+
10+
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
11+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
12+
}
13+
14+
set_time_limit(0);
15+
16+
require dirname(__DIR__).'/vendor/autoload.php';
17+
18+
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
19+
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
20+
}
21+
22+
$input = new ArgvInput();
23+
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
24+
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
25+
}
26+
27+
if ($input->hasParameterOption('--no-debug', true)) {
28+
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
29+
}
30+
31+
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
32+
33+
if ($_SERVER['APP_DEBUG']) {
34+
umask(0000);
35+
36+
if (class_exists(Debug::class)) {
37+
Debug::enable();
38+
}
39+
}
40+
41+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
42+
$application = new Application($kernel);
43+
$application->run($input);

bin/phpunit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
5+
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
6+
exit(1);
7+
}
8+
9+
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
10+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
11+
}
12+
13+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';

composer.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"require": {
5+
"php": ">=7.2.5",
6+
"ext-ctype": "*",
7+
"ext-iconv": "*",
8+
"composer/package-versions-deprecated": "^1.11",
9+
"doctrine/doctrine-bundle": "^2.1",
10+
"doctrine/doctrine-migrations-bundle": "^3.0",
11+
"doctrine/orm": "^2.7",
12+
"friendsofsymfony/rest-bundle": "^3.0",
13+
"jms/serializer-bundle": "^3.7",
14+
"symfony/console": "5.1.*",
15+
"symfony/dotenv": "5.1.*",
16+
"symfony/flex": "^1.3.1",
17+
"symfony/framework-bundle": "5.1.*",
18+
"symfony/yaml": "5.1.*"
19+
},
20+
"require-dev": {
21+
"symfony/phpunit-bridge": "^5.1"
22+
},
23+
"config": {
24+
"optimize-autoloader": true,
25+
"preferred-install": {
26+
"*": "dist"
27+
},
28+
"sort-packages": true
29+
},
30+
"autoload": {
31+
"psr-4": {
32+
"App\\": "src/"
33+
}
34+
},
35+
"autoload-dev": {
36+
"psr-4": {
37+
"App\\Tests\\": "tests/"
38+
}
39+
},
40+
"replace": {
41+
"paragonie/random_compat": "2.*",
42+
"symfony/polyfill-ctype": "*",
43+
"symfony/polyfill-iconv": "*",
44+
"symfony/polyfill-php72": "*",
45+
"symfony/polyfill-php71": "*",
46+
"symfony/polyfill-php70": "*",
47+
"symfony/polyfill-php56": "*"
48+
},
49+
"scripts": {
50+
"auto-scripts": {
51+
"cache:clear": "symfony-cmd",
52+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
53+
},
54+
"post-install-cmd": [
55+
"@auto-scripts"
56+
],
57+
"post-update-cmd": [
58+
"@auto-scripts"
59+
]
60+
},
61+
"conflict": {
62+
"symfony/symfony": "*"
63+
},
64+
"extra": {
65+
"symfony": {
66+
"allow-contrib": false,
67+
"require": "5.1.*"
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)