Skip to content

Commit 1d72a29

Browse files
authored
Merge pull request #390 from Trim/container-compose
Container compose
2 parents d802918 + 06e3ef2 commit 1d72a29

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

Docker.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ LinuxFr on Docker
22
-----------------
33

44
To simplify set up of a developement environment, LinuxFr.org can be
5-
run on Docker with `docker-compose up`.
5+
run on Docker with `docker compose up`.
66

77
To init the SQL database schema, you need to wait upto the `database`
88
container to be ready to listen MySQL connections.
@@ -18,7 +18,7 @@ Or you can check the `database` container status to be "healthy".
1818
Then, open a second terminal and run:
1919

2020
```
21-
docker-compose exec linuxfr.org bin/rails db:setup
21+
docker compose exec linuxfr.org bin/rails db:setup
2222
```
2323

2424
Finally, the environment is ready and you can open [http://dlfp.lo](http://dlfp.lo)
@@ -45,7 +45,7 @@ service.
4545

4646
If you want to change the application port and/or other configurations, you can
4747
[override](https://docs.docker.com/compose/extends/)
48-
the docker-compose configuration (in particular the `nginx` service for
48+
the docker compose configuration (in particular the `nginx` service for
4949
the port).
5050

5151
Notice, that if LinuxFr.org doesn't run on port 80, the image cache
@@ -54,7 +54,7 @@ service won't work well and so you won't be able to see images in the news.
5454
Test modifications
5555
==================
5656

57-
The docker-compose is currently configured to share `./app`, `./db` and
57+
The docker compose is currently configured to share `./app`, `./db` and
5858
`./public` directories with the docker container.
5959

6060
So you can update files with your prefered IDE on your machine. Rails
@@ -64,7 +64,7 @@ Furthermore, if you need to access the Rails console, you need a second
6464
terminal and run:
6565

6666
```
67-
docker-compose run linuxfr.org bin/rails console
67+
docker compose exec linuxfr.org bin/rails console
6868
```
6969

7070
Note: currently, we didn't configure rails to show directly the
@@ -84,7 +84,7 @@ To get help about writing tests, see the
8484
To run tests with Docker environment, you need to use this command:
8585

8686
```
87-
docker-compose run linuxfr.org bin/rails test -v
87+
docker compose exec linuxfr.org bin/rails test -v
8888
```
8989

9090
Inspect the database schema
@@ -104,20 +104,20 @@ In case you need to apply new database migrations, you need a second
104104
terminal and run:
105105

106106
```
107-
docker-compose run linuxfr.org bin/rails db:migrate
107+
docker compose exec linuxfr.org bin/rails db:migrate
108108
```
109109

110110
If you had issue and want to reset all data in your database system,
111111
use:
112112

113113
```
114-
docker-compose run linuxfr.org bin/rails db:reset
114+
docker compose exec linuxfr.org bin/rails db:reset
115115
```
116116

117-
Services provided by the docker-compose
117+
Services provided by the docker compose
118118
=======================================
119119

120-
Currently, these services are directly enabled by docker-compose:
120+
Currently, these services are directly enabled by docker compose:
121121

122122
1. The [LinuxFr.org](https://github.com/linuxfrorg/linuxfr.org)
123123
ruby on rails application itself
@@ -134,7 +134,7 @@ For now, these services aren't available:
134134
because it requires to run
135135
LinuxFr.org with a TLS certificate. When the service will accept to
136136
fetch articles with simple `http://`, we'll be able to provide it
137-
directly with docker-compose.
137+
directly with docker compose.
138138
2. The [svgtex service](https://github.com/linuxfrorg/svgtex), because LinuxFr
139139
has hard-coded the `localhost`
140140
hostname in it's [HTML Pipeline tool](https://github.com/linuxfrorg/html-pipeline-linuxfr/blob/linuxfr/lib/html/pipeline/linuxfr.rb#L8)

docker-compose.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ services:
1818
tmpfs:
1919
- /linuxfr.org/public/tmp:size=100M
2020
healthcheck:
21-
test: curl --fail http://localhost:3000
21+
test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:3000"]
22+
interval: 10s
23+
start_period: 5s
2224
depends_on:
2325
database:
2426
condition: service_healthy
@@ -33,7 +35,9 @@ services:
3335
env_file:
3436
- deployment/default.env
3537
healthcheck:
36-
test: curl --fail -I http://localhost:9000
38+
test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:9000"]
39+
interval: 10s
40+
start_period: 5s
3741
depends_on:
3842
redis:
3943
condition: service_healthy
@@ -45,7 +49,9 @@ services:
4549
env_file:
4650
- deployment/default.env
4751
healthcheck:
48-
test: curl --fail http://localhost:8000/status
52+
test: ["CMD", "curl", "--silent", "--fail", "--head", "http://localhost:8000/status"]
53+
interval: 10s
54+
start_period: 5s
4955
depends_on:
5056
redis:
5157
condition: service_healthy
@@ -66,8 +72,16 @@ services:
6672
published: 127.0.0.1:80
6773
protocol: tcp
6874
healthcheck:
69-
test: curl --fail http://$$DOMAIN && curl --fail http://$$DOMAIN/img && curl --fail -I http://$$DOMAIN/b
75+
test: ["CMD", "curl", "--silent", "--fail", "--fail-early", "--head", "http://$$DOMAIN", "http://$$DOMAIN/img", "http://$$DOMAIN/b", "http://$$IMAGE_DOMAIN/status"]
76+
interval: 10s
77+
start_period: 5s
7078
depends_on:
79+
database:
80+
condition: service_healthy
81+
restart: true
82+
redis:
83+
condition: service_healthy
84+
restart: true
7185
linuxfr.org:
7286
condition: service_healthy
7387
restart: true
@@ -77,6 +91,11 @@ services:
7791
linuxfr-img:
7892
condition: service_healthy
7993
restart: true
94+
networks:
95+
default:
96+
aliases:
97+
- ${DOMAIN}
98+
- ${IMAGE_DOMAIN}
8099

81100
database:
82101
build:
@@ -88,14 +107,18 @@ services:
88107
published: 127.0.0.1:3306
89108
protocol: tcp
90109
healthcheck:
91-
test: mysql -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD --execute "SHOW DATABASES;"
110+
test: ["CMD", "mysql", "-h", "127.0.0.1", "-u", "$$MYSQL_USER", "--password=$$MYSQL_PASSWORD", "--execute", "\"SHOW DATABASES;\""]
111+
interval: 10s
112+
start_period: 5s
92113
volumes:
93114
- data-database:/var/lib/mysql
94115

95116
redis:
96117
image: docker.io/redis:5
97118
healthcheck:
98-
test: redis-cli --raw incr ping
119+
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
120+
interval: 10s
121+
start_period: 5s
99122
volumes:
100123
- data-redis:/data
101124

0 commit comments

Comments
 (0)