Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Full docker app#80

Merged
tgalopin merged 2 commits into
masterfrom
docker-app
Jan 25, 2017
Merged

Full docker app#80
tgalopin merged 2 commits into
masterfrom
docker-app

Conversation

@HeahDude
Copy link
Copy Markdown
Contributor

@HeahDude HeahDude commented Jan 11, 2017

  • wait for MariaDB to be ready
  • update the doc
  • fixes the assets task (build the assets)
  • check if the virtual host is not broken

Comment thread Makefile Outdated

db:
$(CONSOLE) doctrine:database:create --if-not-exists
- $(CONSOLE) doctrine:schema:create
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est quoi le signe moins ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It continues the script on error.

Comment thread docs/1. Installer le projet en local.md Outdated
lancez simplement ``make boot`` à la racine du projet ou la commande `docker-compose up -d`.
Cela créera un serveur MariaDB accessible sur le port 3306 de votre machine (si vous êtes sous Mac OS ou Windows,
vous aurez besoin de travailler avec l'IP de votre machine virtuelle).
Cela créera un serveur apache accessible sur le port 8080 (que vous pouvez personnaliser dans
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/apache/Apache/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thx!

Comment thread docs/1. Installer le projet en local.md Outdated
machine (si vous êtes sous Mac OS ou Windows, vous aurez besoin de travailler avec l'IP de votre
machine virtuelle).

Si vous utilisez Docker, la base de donnée sera configurée automatiquement.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/donnée/données/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

->add('lastName', TextType::class)
->add('emailAddress', EmailType::class)
->add('emailAddress', EmailType::class, [
'empty_data' => '',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix, it activates the transformer null => '', see symfony/symfony#18357 :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->gender = Genders::MALE;
$this->position = ActivityPositions::EMPLOYED;
$this->conditions = false;
$this->emailAddress = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix when submitting null, prevents a fatal error.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please edit the function signature to be consistent with the rest of code.

@HeahDude HeahDude force-pushed the docker-app branch 5 times, most recently from 748da40 to dab2b56 Compare January 11, 2017 16:00
Comment thread web/app_dev.php Outdated
use Symfony\Component\Debug\Debug;

if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')) {
if ('docker' !== getenv('SYMFONY_ENV') && (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server'))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYMFONY_ENV is usually a reference to a Symfony environment, and the docker environment is not a valid Symfony environment. I think we should use a different env var name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgalopin Fair enough, what about DOCKER_ENV=1?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me

@HeahDude
Copy link
Copy Markdown
Contributor Author

@hhamon Final review? :)

Copy link
Copy Markdown
Contributor Author

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs work here. I should upgrade the readme to explain more how to launch the server.

Comment thread Makefile Outdated
all: boot install assets run
.PHONY: clean

all: boot install db assets run
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run is broken with Docker.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then keep bin/console server:run

Comment thread docker-compose.override.yml.dist Outdated
- "3306:3306"

mailcatcher:
ports:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need to override this ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mailcatcher can be removed, we are using mailjet directly without SMTP.

Comment thread docker-compose.yml

mysql:
image: mariadb
environment:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove these default values ? there is no gain to put them in the override file.

Comment thread docker-compose.yml Outdated
mailcatcher:
image: schickling/mailcatcher
ports:
- "9025:1025"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

actually your docker-compose env, should be able to run without the override file. the override file will be used only by devs who want to tweak some stuffs

$this->gender = Genders::MALE;
$this->position = ActivityPositions::EMPLOYED;
$this->conditions = false;
$this->emailAddress = '';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please edit the function signature to be consistent with the rest of code.

Comment thread web/app_dev.php Outdated
use Symfony\Component\Debug\Debug;

if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')) {
if ('1' != getenv('DOCKER_ENV') && (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server'))) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

->add('lastName', TextType::class)
->add('emailAddress', EmailType::class)
->add('emailAddress', EmailType::class, [
'empty_data' => '',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost
Copy link
Copy Markdown

ghost commented Jan 19, 2017

I've just updated this PR. Still need to do :

  • wait for MariaDB to be ready
  • update the doc
  • fixes the assets task (build the assets)
  • check if the virtual host is not broken
  • improves phpMyAdmin if needed (check how it works)

@ghost ghost closed this Jan 19, 2017
@ghost ghost reopened this Jan 19, 2017
Comment thread Makefile
$(CONSOLE) cache:clear --no-warmup
$(CONSOLE) cache:clear --no-warmup --env=prod
$(CONSOLE) cache:clear --no-warmup --env=test
$(APP) rm -rf var/logs/*
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deletes .gitkeep files :/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think, rm don't touch dotfiles

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Comment thread docker-compose.override.yml.dist Outdated
@@ -19,8 +21,8 @@ services:

mailcatcher:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a rebase on master

Comment thread docs/1. Installer le projet en local.md Outdated
ou

- PHP 7.0+
- PHP 7.1+
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be reverted.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but maybe it's not a good idea to develop on 7.1 if we are requiring only 7.0?

https://github.com/EnMarche/en-marche.fr/blob/master/docker/tools/Dockerfile#L1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So? Go for 7.0 or 7.1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go 7.0 for now

Comment thread docs/1. Installer le projet en local.md Outdated

ou

- PHP 7.1+
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 7.0 to be iso prod.

@ghost ghost force-pushed the docker-app branch from 3dfaded to 40c07b2 Compare January 20, 2017 16:13
@HeahDude
Copy link
Copy Markdown
Contributor Author

LGTM 👍, thanks @romain-pierre :)

Comment thread .gitignore
/app/data/images/*
!/app/data/images
!/app/data/images/.gitkeep
/app/data/images/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the gitkeep? I like to be able to understand the directory structure of the project in git. This is true for the other directories like this one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just because using ! sign have no effect on the files already added in the Git index. I prefer to ignore an entire folder and manually add the .gitkeep file in the index (ie: added by force, regardless of the ignore list).

By this way, the folder and it's contents will always be ignored AND the folder will be created thanks to the .gitkeep file AND there is no useless line in the gitignore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

Comment thread docker-compose.override.yml.dist Outdated
- "3306:3306"

mailcatcher:
ports:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mailcatcher can be removed, we are using mailjet directly without SMTP.

@ghost ghost force-pushed the docker-app branch 3 times, most recently from d051c2d to 88b6303 Compare January 24, 2017 17:42
Comment thread docker-compose.yml Outdated
- db
volumes:
- .:/var/www
- /var/www/var/cache
Copy link
Copy Markdown
Contributor

@tgalopin tgalopin Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, why put this and the sessions as a volume?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exclusion rule.

Comment thread docker/app/000-default.conf Outdated

<Directory /var/www/web>
Require all granted
DirectoryIndex app.php
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pas app_dev.php ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like you want, but personally I prefer to have the production bootstrap script when the user request http://127.0.0.1/ and manually specify http://127.0.0.1/app_dev.php/ for development.

Copy link
Copy Markdown

@ghost ghost Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that are the Symfony Standard htaccess rules.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer app_dev.php if you can change this, just to be easier for the newcomers.

Comment thread docker/nginx.conf
@@ -1,65 +0,0 @@
daemon off;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut pas supprimer ca, c'est utilisé pour la preprod.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will revert, but if we switch back to nginx in the future, this file will be located in a sub-folder (probably /docker/web/nginx.conf) to have a clear config.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll work on this PR tonight.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just updated. I will post some comments on the /Dockerfile.

@ghost ghost force-pushed the docker-app branch from 88b6303 to 9c0bd15 Compare January 24, 2017 20:01
@ghost ghost force-pushed the docker-app branch from 9c0bd15 to e8f7945 Compare January 24, 2017 20:03
@ghost
Copy link
Copy Markdown

ghost commented Jan 24, 2017

For the Dockerfile (the production one):

  • I suggest to not use the alpine edition (built on a special glibc that we may not trust)
  • You can avoid to set permissions on chmod a+x /usr/local/bin/run.sh if you set the permissions on your local computer and commit the chmod with Git.
  • If you copy the entire project in the image, it's useless to copy the config file: just move them in the RUN section

@tgalopin
Copy link
Copy Markdown
Contributor

That's true, I'm working on a new ubuntu 16.04 image, and I'll take your ideas into account.

@tgalopin
Copy link
Copy Markdown
Contributor

I changed quite a lot of things:

  • I created 3 Docker files: prod.dockerfile, dev.dockerfile and tools.dockerfile, all based on ubuntu 16.04
  • I installed in these images PHP 7.1: we can start to code using it
  • The docker set-up will from now on be the only supported development environment: I will remove the documentation about server:run and I will explain in more details how to use the Makefile

Comment thread Makefile Outdated
ifdef DOCKER
APP=docker-compose exec -T app
TOOLS=docker-compose run --rm tools
APP=sudo docker-compose exec -T app
Copy link
Copy Markdown

@ghost ghost Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sudo is not required on every platforms for this command to works: on linux, user may be added in the docker group. And macOS not needs privilege elevation at all.

It's a "hard to resolve" point...

Comment thread dev.dockerfile
php7.1-zip \
supervisor \
tzdata \
wget && \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add graphviz? We may need it to dump workflows as dot files.

@tgalopin tgalopin force-pushed the docker-app branch 2 times, most recently from 51c664b to 25f27fc Compare January 25, 2017 10:42
@HeahDude
Copy link
Copy Markdown
Contributor Author

👍

@tgalopin tgalopin merged commit 36e1b28 into master Jan 25, 2017
tgalopin pushed a commit that referenced this pull request Jan 26, 2017
* Added a docker container for the application

* Finalize Dockerized app
@tgalopin tgalopin deleted the docker-app branch January 27, 2017 20:52
@tgalopin tgalopin restored the docker-app branch January 27, 2017 20:52
@tgalopin tgalopin deleted the docker-app branch January 27, 2017 20:52
csauvage pushed a commit to csauvage/en-marche.fr that referenced this pull request Feb 13, 2017
* Added a docker container for the application

* Finalize Dockerized app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants