You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will create a new folder called "django-corporate-dashboard" with the project code.
@@ -25,10 +23,10 @@ Step 2: Dockerize the Django Project
25
23
26
24
Next, navigate to the project directory and run the application with the following command:
27
25
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
+
```
32
30
33
31
Make sure the container is running properly. You can now open your browser and access the application at [http://localhost:5085](http://localhost:5085/).
34
32
@@ -49,19 +47,18 @@ Let's understand how the auto-reload feature works. It utilizes the `docker volu
49
47
50
48
1. In the `Dockerfile`, you will find the following configuration:
51
49
52
-
DockerfileCopy code
53
-
54
-
`WORKDIR /app
50
+
```
51
+
WORKDIR /app
55
52
RUN chmod +x /app/entrypoint.sh
56
-
CMD ["bash", "-c", "/app/entrypoint.sh"]`
53
+
CMD ["bash", "-c", "/app/entrypoint.sh"]
54
+
```
57
55
58
56
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.
59
57
60
58
1. In the `entrypoint.sh` file, you will find the following code:
61
59
62
-
bashCopy code
63
-
64
-
`#!/bin/bash
60
+
```
61
+
#!/bin/bash
65
62
set -e
66
63
67
64
# Function to start Gunicorn with dynamic reload-extra-file options
@@ -75,16 +72,17 @@ start_gunicorn() {
75
72
}
76
73
77
74
# Start Gunicorn
78
-
start_gunicorn`
75
+
start_gunicorn
76
+
```
79
77
80
78
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.
81
79
82
80
1. In the `docker-compose.yml` file, you will find the following configuration:
83
81
84
-
yamlCopy code
85
-
86
-
`volumes:
87
-
- ./:/app`
82
+
```
83
+
volumes:
84
+
- ./:/app
85
+
```
88
86
89
87
This configuration maps the files inside the Docker container, located at `/app`, to the current directory `./` on your host machine.
0 commit comments