Skip to content

Commit 9364fc8

Browse files
authored
Update docker-auto-reload.mdx
1 parent cd92ef1 commit 9364fc8

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

docs/technologies/django/docker-auto-reload.mdx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Step 1: Create a Django Project
1414

1515
To get started, clone our example code by running the following command:
1616

17-
shellCopy code
18-
1917
`$ git clone https://github.com/app-generator/django-corporate-dashboard`
2018

2119
This will create a new folder called "django-corporate-dashboard" with the project code.
@@ -25,10 +23,10 @@ Step 2: Dockerize the Django Project
2523

2624
Next, navigate to the project directory and run the application with the following command:
2725

28-
shellCopy code
29-
30-
`$ cd django-corporate-dashboard
31-
$ docker compose up -d --build`
26+
```
27+
$ cd django-corporate-dashboard
28+
$ docker compose up -d --build
29+
```
3230

3331
Make sure the container is running properly. You can now open your browser and access the application at [http://localhost:5085](http://localhost:5085/).
3432

@@ -49,19 +47,18 @@ Let's understand how the auto-reload feature works. It utilizes the `docker volu
4947

5048
1. In the `Dockerfile`, you will find the following configuration:
5149

52-
DockerfileCopy code
53-
54-
`WORKDIR /app
50+
```
51+
WORKDIR /app
5552
RUN chmod +x /app/entrypoint.sh
56-
CMD ["bash", "-c", "/app/entrypoint.sh"]`
53+
CMD ["bash", "-c", "/app/entrypoint.sh"]
54+
```
5755

5856
These configurations ensure that the application is stored in the `/app` directory and that the `entrypoint.sh` script is executed every time the container is run.
5957

6058
1. In the `entrypoint.sh` file, you will find the following code:
6159

62-
bashCopy code
63-
64-
`#!/bin/bash
60+
```
61+
#!/bin/bash
6562
set -e
6663
6764
# Function to start Gunicorn with dynamic reload-extra-file options
@@ -75,16 +72,17 @@ start_gunicorn() {
7572
}
7673
7774
# Start Gunicorn
78-
start_gunicorn`
75+
start_gunicorn
76+
```
7977

8078
This code scans all files with the `.html` extension, and whenever any of these files change, Gunicorn will automatically reload the server. We don't need to add `.py` files in the `entrypoint.sh` because Gunicorn automatically detects changes in `.py` files.
8179

8280
1. In the `docker-compose.yml` file, you will find the following configuration:
8381

84-
yamlCopy code
85-
86-
`volumes:
87-
- ./:/app`
82+
```
83+
volumes:
84+
- ./:/app
85+
```
8886

8987
This configuration maps the files inside the Docker container, located at `/app`, to the current directory `./` on your host machine.
9088

0 commit comments

Comments
 (0)