Skip to content

Commit db2be56

Browse files
developer@nicolas-grevin.comnicolas-grevin
developer@nicolas-grevin.com
authored andcommitted
article(upgrade-docker)
1 parent 5693e08 commit db2be56

File tree

19 files changed

+108
-297
lines changed

19 files changed

+108
-297
lines changed

.env.dist

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
# APP
2-
SYMFONY_APP_PATH=/
2+
APP_DIR=/var/www/symfony
33

4-
# DOCKER
5-
LOGS_DIR=/docker/logs
4+
# Symfony
5+
APP_ENV=dev
6+
APP_DEBUG=1
7+
SECRET=
8+
9+
# NODE
10+
NODE_ENV=dev
611

712
# DATABASE
13+
POSTGRES_HOST=
814
POSTGRES_DB=
915
POSTGRES_USER=
1016
POSTGRES_PASSWORD=
1117
POSTGRES_PORT=
1218

13-
# PORT WEB
14-
WEB_PORT=
15-
ELK_PORT=
16-
17-
# SYMFONY
18-
SECRET=
19-
2019
#SMTP
2120
SMTP_USER=
2221
SMTP_PASSWORD=
2322
SMTP_HOST=
2423
SMTP_TRANSPORT=
2524

25+
# PORT WEB
26+
WEB_PORT=
27+
2628
#REDIS
2729
REDIS_DSN=

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
### PHPUnit
2222
/phpunit.xml
2323

24-
### Docker
25-
docker/logs/
26-
2724
### NodeJS - NPM - YARN
2825
node_modules/
2926
npm-debug.log*

app/config/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ snc_redis:
8686
type: predis
8787
logging: false
8888
alias: session_client
89-
dsn: %redis_dsn%
90-
options: %redis_options%
89+
dsn: '%redis_dsn%'
90+
options: '%redis_options%'
9191
session:
9292
client: session_client
9393
prefix: app_session_

app/config/parameters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77
database_password: '%env(POSTGRES_PASSWORD)%'
88

99
# Mailer parameters
10-
mailer_transport: %env(SMTP_TRANSPORT)%
10+
mailer_transport: '%env(SMTP_TRANSPORT)%'
1111
mailer_host: '%env(SMTP_HOST)%'
1212
mailer_user: '%env(SMTP_USER)%'
1313
mailer_password: '%env(SMTP_PASSWORD)%'
@@ -16,6 +16,6 @@ parameters:
1616
secret: '%env(SECRET)%'
1717

1818
# Redis parameters
19-
redis_dsn: '%env(REDIS_DSN)%'
19+
redis_dsn: 'redis://%env(REDIS_DSN)%'
2020
redis_options: ~
2121
session_ttl: 86400

bin/app

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ stop ()
5353
docker-compose stop
5454
}
5555

56-
# run bash
57-
bash ()
56+
# run sh
57+
sh ()
5858
{
59-
docker-compose exec --user www-data php bash
59+
docker-compose exec --user www-data php sh
6060
}
6161

6262
# exec a command into app container (as root)
@@ -105,7 +105,7 @@ usage ()
105105
init Initialize project
106106
start Start project
107107
stop Stop project
108-
bash Use bash inside the app container
108+
sh Use sh inside the app container
109109
exec Executes a command inside the app container
110110
destroy Remove all the project Docker containers with their volumes
111111
console Use the Symfony console
@@ -123,7 +123,7 @@ main ()
123123
exit 0
124124
fi
125125

126-
if [[ ! $1 =~ ^init|start|stop|bash|destroy|console|composer|exec|tests$ ]]; then
126+
if [[ ! $1 =~ ^init|start|stop|sh|destroy|console|composer|exec|tests$ ]]; then
127127
echo "$1 is not a supported command"
128128
exit 1
129129
fi

bin/console

100755100644
File mode changed.

docker-compose.yml

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,44 @@
1-
version: '2'
1+
version: '3'
22

33
services:
4-
postgres:
5-
image: postgres:9.6
6-
ports:
7-
- ${POSTGRES_PORT}:5432
8-
environment:
9-
POSTGRES_DB: ${POSTGRES_DB}
10-
POSTGRES_USER: ${POSTGRES_USER}
11-
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
4+
postgres:
5+
image: postgres:10-alpine
6+
env_file:
7+
- .env
8+
ports:
9+
- ${POSTGRES_PORT}:5432
1210

13-
php:
14-
build: docker/php7-fpm
15-
env_file: ./.env
16-
volumes:
17-
- ${PWD}:/var/www/symfony
18-
links:
19-
- postgres
11+
php:
12+
build:
13+
context: .
14+
dockerfile: docker/php/Dockerfile
15+
env_file:
16+
- .env
17+
user: www-data
18+
working_dir: ${APP_DIR}
19+
volumes:
20+
- ${PWD}:${APP_DIR}
2021

21-
nginx:
22-
build: docker/nginx
23-
ports:
24-
- ${WEB_PORT}:80
25-
volumes_from:
26-
- php
27-
volumes:
28-
- ${LOGS_DIR}/nginx/:/var/log/nginx
22+
nginx:
23+
build:
24+
context: .
25+
dockerfile: docker/nginx/Dockerfile
26+
ports:
27+
- ${WEB_PORT}:80
28+
volumes:
29+
- ${PWD}:${APP_DIR}
2930

30-
elk:
31-
image: willdurand/elk
32-
ports:
33-
- ${ELK_PORT}:80
34-
volumes:
35-
- ./docker/elk/logstash:/etc/logstash
36-
- ./docker/elk/logstash/patterns:/opt/logstash/patterns
37-
volumes_from:
38-
- php
39-
- nginx
31+
redis:
32+
image: redis:4-alpine
4033

41-
redis:
42-
image: redis:3.2.10
43-
44-
node:
45-
build: docker/node
46-
volumes:
47-
- ${SYMFONY_APP_PATH}:/var/www/symfony
48-
command: bash -c "yarn && yarn dev"
34+
node:
35+
build:
36+
context: .
37+
dockerfile: docker/node/Dockerfile
38+
env_file:
39+
- .env
40+
user: node
41+
working_dir: ${APP_DIR}
42+
volumes:
43+
- ${PWD}:${APP_DIR}
44+
command: sh -c "yarn && yarn dev"

docker/elk/logstash/logstash.conf

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

docker/elk/logstash/patterns/default.conf

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

docker/elk/logstash/patterns/nginx.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

docker/elk/logstash/patterns/symfony.conf

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

docker/nginx/Dockerfile

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
FROM debian:jessie
1+
FROM nginx:1.13-alpine
22

3-
MAINTAINER Maxence POUTORD <maxence.poutord@gmail.com>
3+
RUN apk --no-cache add shadow
44

5-
RUN apt-get update && apt-get install -y \
6-
nginx
5+
RUN rm -f /etc/nginx/nginx.conf /etc/nginx/conf.d/*
76

8-
ADD nginx.conf /etc/nginx/
9-
ADD symfony.conf /etc/nginx/sites-available/
7+
ADD ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
8+
ADD ./docker/nginx/upstream.conf /etc/nginx/conf.d/upstream.conf
9+
ADD ./docker/nginx/symfony.conf /etc/nginx/conf.d/symfony.conf
1010

11-
RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/symfony
12-
RUN rm /etc/nginx/sites-enabled/default
13-
14-
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
15-
16-
RUN usermod -u 1000 www-data
17-
18-
CMD ["nginx"]
19-
20-
EXPOSE 80
21-
EXPOSE 443
11+
RUN addgroup -g 1000 -S www-data && \
12+
adduser -u 1000 -D -S -G www-data www-data

0 commit comments

Comments
 (0)