Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 97834a26 authored by Julien Fastré's avatar Julien Fastré

first bootstrap with docker and docker-compose

parent e417c1b6
......@@ -12,7 +12,6 @@
/composer.phar
*~
.DS_Store
composer.lock
web/css/
web/js/
# forget about migration files
......@@ -23,3 +22,6 @@ app/DoctrineMigrations/*
.project
.settings/
/nbproject/private/
.env
.composer/*
FROM php:7.2-fpm
MAINTAINER Julien Fastré <julien.fastre@champs-libres.coop>
ENV PHPREDIS_VERSION 4.0.0
# Set the lifetime of a PHP session
ARG SESSION_LIFETIME=10800
# default UID for the PHP user
ARG UID=1000
RUN apt update && apt -y --no-install-recommends install wget gnupg \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt update && apt -y --no-install-recommends install \
libicu-dev \
g++ \
postgresql-server-dev-10 \
libzip-dev \
libfreetype6-dev \
libpng-dev \
libjpeg62-turbo-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install intl pdo_pgsql mbstring zip bcmath sockets exif \
&& mkdir /tmp/redis \
&& curl -L -o /tmp/redis/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& cd /tmp/redis \
&& tar xfz /tmp/redis/redis.tar.gz \
&& rm -r /tmp/redis/redis.tar.gz \
&& mkdir -p /usr/src/php/ext/redis \
&& mv /tmp/redis/phpredis-$PHPREDIS_VERSION/* /usr/src/php/ext/redis/. \
&& docker-php-ext-install redis \
&& apt remove -y wget libicu-dev g++ gnupg libpng-dev libzip-dev libfreetype6-dev \
&& apt autoremove -y \
&& apt purge -y
RUN { \
echo ""; \
echo "[Date]"; \
echo "date.timezone = Europe/Brussels"; \
echo ""; \
} >> /usr/local/etc/php/conf.d/date.ini
# register session in redis and store password
RUN { \
echo ""; \
echo "session.save_handler = redis" ; \
echo "session.save_path = \"tcp://redis:6379?db=10\"" ; \
echo "session.gc_maxlifetime = ${SESSION_LIFETIME}" ; \
} >> /usr/local/etc/php/conf.d/custom.ini
WORKDIR /var/www/app
COPY ./app /var/www/app/app/.
COPY ./bin /var/www/app/bin/.
COPY ./src /var/www/app/src/.
COPY ./vendor /var/www/app/vendor/.
COPY ./web /var/www/app/web/.
COPY ./composer.* /var/www/app/
ADD ./entrypoint.sh /.
RUN chmod u+x /entrypoint.sh
# && chown www-data:www-data var/logs -R \
# && chown www-data:www-data var/cache -R
# ajoute des utilisateurs ayant le uid 1000
RUN useradd --uid ${UID} --create-home "user${UID}"
ENV DATABASE_HOST=db \
DATABASE_PORT=5432 \
DATABASE_NAME=postgres \
DATABASE_USER=postgres \
LOCALE=fr \
REDIS_HOST=redis \
REDIS_PORT=6379 \
PHP_FPM_USER=www-data \
PHP_FPM_GROUP=www-data
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
......@@ -6,52 +6,86 @@ The Chill project is a fork of [symfony/symfony-standard]
file to adapt to chill installation.
1) Installing Chill
----------------------------------
This project use [docker](https://docker.com) to be run. As a developer, use [docker-compose](https://docs.docker.com/compose/overview/) to bootstrap a dev environment in a glance.
### Use Composer (*recommended*)
## As a developer
As Symfony uses [Composer][2] to manage its dependencies, the recommended way
to create a new project is to use it.
Clone or download this project and `cd` into the main directory.
If you don't have Composer yet, download it following the instructions on
http://getcomposer.org/ or just run the following command:
As a developer, the code will stay on your computer and will be executed in docker container. To avoid permission problem, the code should be run with the same uid/gid from your current user. Have a look at those id before continuing.
curl -s http://getcomposer.org/installer | php
### Prepare your variables
Then, use the `create-project` command to generate a new Symfony application:
Have a look at the variable in [`env.dist`](env.dist) and check if you need to adapt them. If they do not adapt with your need, or if some are missing:
php composer.phar create-project chill-project/standard path/to/install
1. copy the file as `.env`: `cp env.dist .env`
2. replace the variable inside `.env`
Composer will install Symfony and all its dependencies under the
`path/to/install` directory.
### Run the bootstrap script
2) Checking your System Configuration
-------------------------------------
This script must be run inside the container, without the default `entrypoint`:
Before starting coding, make sure that your local system is properly
configured for Symfony.
```bash
docker-compose run --user <uid> --entrypoint /usr/bin/env php /bin/bash docker/install.dev.sh
```
Execute the `check.php` script from the command line:
This script will :
php app/check.php
1. force docker-compose to, eventually, pull the base images and build the image used by this project ;
2. run an install script to download [`composer`](https://getcomposer.org) ;
3. install the php dependencies
The script returns a status code of `0` if all mandatory requirements are met,
`1` otherwise.
### Start the project
Access the `config.php` script from a browser:
```bash
docker-compose up
```
http://localhost/path-to-project/web/config.php
Now, read the how-tos.
If you get any warnings or recommendations, fix them before moving on.
## How to
### How to execute the console ?
4) Getting started with Chill
-------------------------------
```
# if a container is running
docker-compose exec --user <uid> php app/console
# if not
docker-compose run --user <uid> php app/console
```
TODO
### How to create the database schema (= run migrations) ?
What's inside?
---------------
```
# if a container is running
docker-compose exec --user <uid> php app/console doctrine:migrations:migrate
# if not
docker-compose run --user <uid> php app/console doctrine:migrations:migrate
```
You may read the [Champs-Libres Blog](http://blog.champs-libres.coop) to learn about our project.
### How to load fixtures ?
```
# if a container is running
docker-compose exec --user <uid> php app/console doctrine:fixtures:load
# if not
docker-compose run --user <uid> php app/console doctrine:fixtures:load
```
### How to open a terminal in the project
```
# if a container is running
docker-compose exec --user <uid> php /bin/bash
# if not
docker-compose run --user <uid> php /bin/bash
```
### How to run composer ?
```
# if a container is running
docker-compose exec --user <uid> php ./composer.phar
# if not
docker-compose run --user <uid> php ./composer.phar
```
......@@ -13,6 +13,7 @@ class AppKernel extends Kernel
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\DebugBundle\DebugBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Chill\MainBundle\ChillMainBundle(),
......@@ -38,4 +39,14 @@ class AppKernel extends Kernel
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
public function getCacheDir()
{
return \sys_get_temp_dir().'/app/cache/'.$this->getEnvironment();
}
public function getLogDir()
{
return \sys_get_temp_dir().'/app/logs';
}
}
......@@ -687,6 +687,21 @@ class SymfonyRequirements extends RequirementCollection
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).'
);
if (class_exists('Symfony\Component\Intl\Intl')) {
$this->addRecommendation(
\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion(),
sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()),
'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.'
);
if (\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion()) {
$this->addRecommendation(
\Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(),
sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()),
'To avoid internationalization data inconsistencies upgrade the symfony/intl component.'
);
}
}
$this->addPhpIniRecommendation(
'intl.error_level',
create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
......@@ -718,15 +733,9 @@ class SymfonyRequirements extends RequirementCollection
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$this->addRecommendation(
<<<<<<< HEAD
$this->getRealpathCacheSize() > 1000,
'realpath_cache_size should be above 1024 in php.ini',
'Set "<strong>realpath_cache_size</strong>" to e.g. "<strong>1024</strong>" in php.ini<a href="#phpini">*</a> to improve performance on windows.'
=======
$this->getRealpathCacheSize() >= 5 * 1024 * 1024,
'realpath_cache_size should be at least 5M in php.ini',
'Setting "<strong>realpath_cache_size</strong>" to e.g. "<strong>5242880</strong>" or "<strong>5M</strong>" in php.ini<a href="#phpini">*</a> may improve performance on Windows significantly in some cases.'
>>>>>>> origin/master
);
}
......@@ -765,15 +774,11 @@ class SymfonyRequirements extends RequirementCollection
{
$size = ini_get('realpath_cache_size');
$size = trim($size);
<<<<<<< HEAD
$unit = strtolower(substr($size, -1, 1));
=======
$unit = '';
if (!ctype_digit($size)) {
$unit = strtolower(substr($size, -1, 1));
$size = (int) substr($size, 0, -1);
}
>>>>>>> origin/master
switch ($unit) {
case 'g':
return $size * 1024 * 1024 * 1024;
......@@ -785,8 +790,6 @@ class SymfonyRequirements extends RequirementCollection
return (int) $size;
}
}
<<<<<<< HEAD
=======
/**
* Defines PHP required version from Symfony version.
......@@ -811,5 +814,4 @@ class SymfonyRequirements extends RequirementCollection
return false;
}
>>>>>>> origin/master
}
......@@ -60,3 +60,12 @@ doctrine:
chill_main:
available_languages: [ fr ]
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
port: "%mailer_port%"
......@@ -55,19 +55,17 @@ web_profiler:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
## log to graylog and docker
## start elastic search : docker run --rm -p 9200:9200 -p 9300:9300 --name es_container elasticsearch
## start logstash : docker run --rm -p 12201:12201/udp --link es_container:es logstash logstash -e 'input { gelf { } } output { elasticsearch { hosts => "es"} }'
# graylog:
# type: gelf
# publisher:
# hostname: localhost
# port: 12201
# level: debug
graylog:
type: gelf
publisher:
hostname: "logstash"
port: 12201
level: debug
channels: ['!event']
console:
type: console
process_psr_3_messages: false
channels: ['!event', '!doctrine', '!console']
console:
type: console
bubble: false
......
parameters:
admin_password: change_this
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
debug_toolbar: true
debug_redirects: false
admin_password: admin
database_host: db
database_port: 5432
database_name: postgres
database_user: postgres
database_password: postgres
locale: fr
secret: ThisTokenIsNotSoSecretChangeIt
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
mailer_transport: smtp
mailer_host: smtp
mailer_user: ~
mailer_password: ~
mailer_port: 25
This diff is collapsed.
version: '3'
services:
php: &php-definition
build:
context: .
args:
UID: ${PHP_FPM_USER:-1000}
volumes:
- .:/var/www/app
environment:
- "COMPOSER_HOME=/var/www/app/.composer"
- "DEBUG=${DEBUG:-true}"
- "ENV=${ENV:-dev}"
- "PHP_FPM_USER=${PHP_FPM_USER:-1000}"
- "PHP_FPM_GROUP=${PHP_FPM_GROUP:-1000}"
links:
- db
- redis
- smtp
- logstash
nginx:
build:
context: .
dockerfile: docker/nginx/Dockerfile
volumes:
- .:/var/www/app
# - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
links:
- php
- logstash
ports:
- "8001:80"
db:
image: postgres:10
ports:
- "5445:5432"
volumes:
- ./docker/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
redis:
image: redis
logstash:
build:
context: ./docker/logstash
# fake smtp server
smtp:
image: schickling/mailcatcher
ports:
- "1080:1080"
#!/bin/sh
echo 'install composer'
EXPECTED_SIGNATURE=$(curl -o /dev/stdout --silent https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php
rm composer-setup.php
echo ''
echo 'composer installed successfully'
echo ''
echo 'install deps'
echo ''
php composer.phar install
echo ''
echo 'deps installed sucessfully'
echo ''
FROM docker.elastic.co/logstash/logstash-oss:6.2.3
RUN \
bin/logstash-plugin install logstash-output-gelf \
&& bin/logstash-plugin install logstash-input-gelf
COPY ./logstash.yml /usr/share/logstash/config/logstash.yml
COPY ./pipeline /usr/share/logstash/pipeline
COPY ./grok_patterns /etc/grok/patterns
NGINXACCESS \A%{URIHOST:http_host}%{SPACE}%{IP:client_ip}%{SPACE}\[%{HTTPDATE:timestamp_date}]%{SPACE}"%{WORD:method} %{URIPATHPARAM:uri} HTTP/%{NUMBER:http_version}" %{NUMBER:status_code_int} %{NUMBER:bytes_sent_num:int} %{QUOTEDSTRING:referrer} %{QUOTEDSTRING:agent} %{NUMBER:response_time_num:float} %{NUMBER:upstream_response_time_num:float}
http.host: "0.0.0.0"
path.config: /usr/share/logstash/pipeline
input {
syslog {
# input for nginx logs
port => 5514
add_field => [ 'source', "nginx" ]
}
gelf {
# input for php logs
port => 12201
add_field => [ 'source', "php" ]
}
}
filter {
# apply grok filter for nginx
if [source] == "nginx" {
grok {
match => { "message" => "%{NGINXACCESS}" }
patterns_dir => [ "/etc/grok/patterns" ]
}
date {
match => [ "timestamp" , "dd/MMM/YYYY:HH:mm:ss Z" ]
}
}
}
FROM nginx:alpine
COPY ./web /var/www/app/web
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
error_log /dev/stderr;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip off;
#include /etc/nginx/conf.d/*.conf;
# permet l'upload de fichiers
client_max_body_size 3M;
upstream phpfcgi {
server php:9000;
# server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}
server {
listen 80;
#server_name symfony2;
root /var/www/app/web;
error_log /dev/stderr;
access_log /dev/stdout main;
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff|ttf|eot|map)$ {
add_header Pragma public;
add_header Cache-Control "public";
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass phpfcgi;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 16k;
proxy_busy_buffers_size 16k;
}
}
}
#!/bin/bash
#immediatly exit if a command fails:
set -e
# waiting for the database to be ready
while ! timeout 1 bash -c "cat < /dev/null > /dev/tcp/${DATABASE_HOST}/${DATABASE_PORT}"
do
echo "$(date) : waiting one second for database";
sleep 1;
done
echo "$(date) : the database is ready";
#migrate
#php /var/www/app/bin/console doctrine:migrations:migrate --no-interaction --env=prod
{ \
echo "[www]"; \
echo ""; \
echo "user=${PHP_FPM_USER}"; \
echo "group=${PHP_FPM_GROUP}"; \
} > /usr/local/etc/php-fpm.d/zz-user.conf
#prepare cache
php /var/www/app/app/console --env=prod cache:clear --no-warmup
chgrp ${PHP_FPM_GROUP} /tmp/app/cache -R && chmod g+rw /tmp/app/cache -R
chgrp ${PHP_FPM_GROUP} /tmp/app/logs -R && chmod g+rw /tmp/app/logs -R
exec "${@}"
# enable or disable debug
DEBUG=true
# environment to run the project
ENV=dev
# the user which run php-fpm. Adapt it to your current uid. (get it with `$ id`)
PHP_FPM_USER=1000
# the group which run php-fpm. Adapt it to your current gid. (get it with `$ id`)
PHP_FPM_GROUP=1000
......@@ -6,7 +6,10 @@ use Symfony\Component\HttpFoundation\Request;
$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$env = \getenv('ENV') !== false ? \getenv('ENV') : 'prod';
$debug = \getenv('DEBUG') === 'true';
$kernel = new AppKernel($env, $debug);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment