Skip to content

Commit 201799e

Browse files
committed
extra useful commands
1 parent 8ae7698 commit 201799e

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

docker-compose-swarm.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
web:
3+
image: quitotactico/softserve-academy
4+
command: ["sh", "/app/scripts/init.sh"]
5+
environment:
6+
- DJANGO_SETTINGS_MODULE=SoftServeAcademy.settings_deployment
7+
depends_on:
8+
- db
9+
ports:
10+
- "80:80"
11+
networks:
12+
- django-network
13+
deploy:
14+
replicas: 5
15+
restart_policy:
16+
condition: on-failure
17+
18+
db:
19+
image: mysql:8.0
20+
environment:
21+
MYSQL_ROOT_PASSWORD: 1234
22+
MYSQL_USER: admin
23+
MYSQL_PASSWORD: 1234
24+
MYSQL_DATABASE: softserve-bd
25+
networks:
26+
- django-network
27+
volumes:
28+
- db_data:/var/lib/mysql
29+
deploy:
30+
replicas: 1
31+
placement:
32+
constraints:
33+
- node.role == manager
34+
35+
networks:
36+
django-network:
37+
38+
volumes:
39+
db_data:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
networks:
1212
- django-network
1313
deploy:
14-
replicas: 3
14+
replicas: 1
1515
restart_policy:
1616
condition: on-failure
1717

readme.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ And that's it. Open your web browser and go to `http://localhost:8000/` if you h
103103
sudo docker compose up -d --pull always
104104
```
105105
106+
4. **Extra:**
107+
You can check the status of the containers with:
108+
```bash
109+
sudo docker container ls
110+
```
111+
Check the logs with:
112+
```bash
113+
sudo docker container logs softserve_web_1
114+
sudo docker container logs softserve_db_1
115+
```
116+
And shut down the containers with:
117+
```bash
118+
sudo docker compose down
119+
```
120+
106121
And that's it! You can now access the application opening your web browser and going to `http://localhost`, or `http://<instance-ip>` if you have it externally. This runs on the port 80 by default.
107122

108123
This creates `a container with the Django application` and another `container with the database (MySQL)`, but with the same migrations and data as the beta SQlite uploaded in this repository.
@@ -140,7 +155,30 @@ This creates `a container with the Django application` and another `container wi
140155

141156
5. **Deploy the stack in the manager:**
142157
```bash
143-
sudo docker stack deploy -c docker-compose.yml softserve
158+
sudo docker stack deploy -c docker-compose-swarm.yml softserve
159+
```
160+
161+
6. **Extra:**
162+
You can check the status of the deployment with:
163+
```bash
164+
sudo docker node ls
165+
sudo docker service ls
166+
sudo docker service ps web
167+
sudo docker service ps db
168+
sudo docker container ls
169+
```
170+
Check the logs with:
171+
```bash
172+
sudo docker service logs web
173+
sudo docker service logs db
174+
```
175+
And shut down the stack with:
176+
```bash
177+
sudo docker stack rm softserve
178+
```
179+
And leave the swarm with:
180+
```bash
181+
sudo docker swarm leave --force
144182
```
145183

146184
You can access the application opening your web browser and going to `http://<manager-ip>/`, this runs on the port 80 by default.

0 commit comments

Comments
 (0)