Skip to content

Commit d8b5433

Browse files
committed
Fixed problems with the Docker-based development environment. Closes #1244
1 parent ab75de2 commit d8b5433

File tree

11 files changed

+85
-70
lines changed

11 files changed

+85
-70
lines changed

.docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LABEL Description="This is the docker image for OpenCFP, a PHP-based conference
1313
RUN docker-php-ext-install pdo_mysql
1414

1515
ENV CFP_ENV ${CFP_ENV:-development}
16-
ENV CFP_DB_HOST ${CFP_DB_HOST:-"127.0.0.1"}
16+
ENV CFP_DB_HOST ${CFP_DB_HOST:-database}
1717
ENV CFP_DB_PASS ${CFP_DB_PASS:-root}
1818

19-
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
19+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

README.md

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,17 @@ mail:
259259
auth_mode: ~
260260
```
261261

262-
As the project migrates from using Eloquent to Doctrine, you also need to edit the following files to ensure the database
263-
credentials are correct:
262+
As the project migrates from using Eloquent to Doctrine you also need to edit the following files to ensure the database
263+
credentials are correct, creating a version of the modified file in the same location but without the `.dist` suffix.
264264

265-
`resources/config/config_testing.yml`
266-
`resources/config/config_development.yml`
267-
`resources/config/config_production.yml`
265+
`resources/config/config_testing.yml.dist`
266+
`resources/config/config_development.yml.dist`
267+
`resources/config/config_production.yml.dist`
268268

269269

270270
### [Running behind a trusted proxy](#run-trusted-proxy)
271271

272-
If you are running OpenCFP behing a proxy server which adds X-Forwarded-For headers (this could be a cloud based load balancer or a service such as Cloudflare) you will need to set the environment variable TRUST_PROXIES to true this will ensure that OpenCFP trusts the headers set by these proxies for the original IP address and ssl mode. Setting this will trust these headers regardless of where the original request originates, so it's advisable to either lock down your instance so that only the trusted proxy can access it or modify the list of trusted proxies in the index.php file to only include the ip addresses of your proxies.
272+
If you are running OpenCFP behind a proxy server which adds X-Forwarded-For headers (this could be a cloud based load balancer or a service such as Cloudflare) you will need to set the environment variable TRUST_PROXIES to true this will ensure that OpenCFP trusts the headers set by these proxies for the original IP address and ssl mode. Setting this will trust these headers regardless of where the original request originates, so it's advisable to either lock down your instance so that only the trusted proxy can access it or modify the list of trusted proxies in the index.php file to only include the ip addresses of your proxies.
273273

274274

275275
### [OpenCFP Central](#opencfp-central)
@@ -365,39 +365,36 @@ settings that machine might have that could differ from the machine used for wri
365365
#### Build & Run the image
366366

367367
Please remember to edit the file `config/docker.yml.dist` to match your environment, then you can build your own
368-
docker image by executing:
368+
docker image by using a [docker-compose](https://docs.docker.com/compose/install/) command which will build the
369+
image and run the containers automatically for you:
369370

370371
```
371-
$ ./.docker/build latest
372+
$ docker-compose -f docker-compose.yml.dist up --build -d
372373
```
373374

374-
And the result will be an image called `opencfp/opencfp:latest`.
375+
So now if you head over to `http://localhost:8080` you will be greeted with a running version of OpenCFP in
376+
`development` mode.
375377

376-
Or if you like you can run [docker-compose](https://docs.docker.com/compose/install/) command which will build the
377-
image and run the containers automatically for you:
378+
After building and running the Docker image you'll need to use the docker-compose [exec](https://docs.docker.com/compose/reference/exec/)
379+
command to configure things inside the container:
378380

381+
```bash
382+
$ docker-compose -f docker-compose.yml.dist exec app composer run setup-docker
379383
```
380-
$ docker-compose -f docker-compose.yml.dist up --build -d
381-
```
382-
383-
So now if you head over to `http://localhost:8080` you will be greeted with a running version of OpenCFP.
384384

385-
After building and running the Docker image you'll need to [Run Migrations](#run-migrations) and [Add an Admin User](#user-management) before logging-in.
385+
and then [Add an Admin User](#user-management) before logging-in.
386386

387387
#### Run PHP commands within the Container
388388

389389
To run any command in the app container you can use the docker-compose
390-
[exec](https://docs.docker.com/compose/reference/exec/) command, for example to run the `setup` script you run:
390+
[exec](https://docs.docker.com/compose/reference/exec/) command, for example to clear the cache for your
391+
environment:
391392

392393
```bash
393-
$ docker-compose -f docker-compose.yml.dist exec app composer run setup-env
394+
$ docker-compose -f docker-compose.yml.dist exec app bin/console cache:clear
394395
```
395396
OR
396397

397-
```bash
398-
$ docker-compose -f docker-compose.yml.dist exec app ./script/setup
399-
```
400-
401398
#### Running the image directly
402399

403400
You can run the image (after you build it) and link it to an already running database container using the docker
@@ -412,7 +409,7 @@ Where `database` is the name of the running database container.
412409

413410
#### Access MySQL container
414411

415-
To access MySQL you can use the following information:
412+
To access the MySQL container from outside the application container you can use the following information:
416413

417414
- **Host**: 127.0.0.1
418415
- **User**: root

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
]
9292
},
9393
"scripts": {
94+
"setup-docker": "./script/docker",
9495
"fix": "php vendor/bin/php-cs-fixer fix --config=.php_cs.dist --using-cache=no",
9596
"make": "make",
9697
"migrate": "./script/migrate",

config/development.yml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ application:
1818
user_image_size: 300
1919

2020
database:
21-
host: 127.0.0.1
21+
host: database
2222
database: cfp
23-
dsn: mysql:dbname=cfp;host=127.0.0.1
23+
dsn: mysql:dbname=cfp;host=database
2424
user: root
25-
password: ~
25+
password: root
2626

2727
log:
2828
level: debug

docker-compose.yml.dist

Lines changed: 0 additions & 39 deletions
This file was deleted.

resources/config/config_development.yml renamed to resources/config/config_development.yml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ oneup_flysystem:
2222

2323
doctrine:
2424
dbal:
25-
url: mysql://root:@127.0.0.1:3306/cfp
25+
url: mysql://root:root@database:3306/cfp
2626
default_table_options:
2727
charset: utf8mb4
2828
collate: utf8mb4_unicode_ci

resources/config/config_production.yml renamed to resources/config/config_docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ oneup_flysystem:
1414

1515
doctrine:
1616
dbal:
17-
url: mysql://root:@127.0.0.1:3306/cfp
17+
url: mysql://root:root@database:3306/cfp
1818
default_table_options:
1919
charset: utf8mb4
2020
collate: utf8mb4_unicode_ci
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
imports:
2+
- { resource: config.yml }
3+
4+
oneup_flysystem:
5+
adapters:
6+
uploads:
7+
local:
8+
directory: "%kernel.root_dir%/../web/uploads"
9+
10+
filesystems:
11+
uploads:
12+
adapter: uploads
13+
alias: upload_filesystem
14+
15+
doctrine:
16+
dbal:
17+
url: mysql://root:root@database:3306/cfp
18+
default_table_options:
19+
charset: utf8mb4
20+
collate: utf8mb4_unicode_ci
21+
orm:
22+
auto_mapping: true
23+
auto_generate_proxy_classes: true
24+
mappings:
25+
OpenCFP\Domain\Entity:
26+
type: annotation
27+
dir: "%kernel.root_dir%/../src/Domain/Entity"
28+
prefix: OpenCFP\Domain\Entity
29+

resources/config/config_testing.yml renamed to resources/config/config_testing.yml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ swiftmailer:
3333

3434
doctrine:
3535
dbal:
36-
url: mysql://cfp_test:cfp_test@127.0.0.1:3306/cfp_test
36+
url: mysql://root:root@127.0.0.1:3306/cfp
3737
default_table_options:
3838
charset: utf8mb4
3939
collate: utf8mb4_unicode_ci

script/bootstrap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ if [ ! -f "config/$CFP_ENV.yml" ]; then
2626
echo "Missing config/$CFP_ENV.yml, be sure to copy from config/$CFP_ENV.yml.dist and update config"
2727
exit 1
2828
fi
29+
30+
31+
echo "==> Clearing caches..."
32+
bin/console --env=$CFP_ENV cache:clear

0 commit comments

Comments
 (0)