You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
3 years ago
|
# django-docker
|
||
|
A complete example for deploying Django project with Nginx and MySQL on Docker.
|
||
|
## QuickStart
|
||
|
Install Docker Engine from the tutorial <https://docs.docker.com/engine/installation/>.</br>
|
||
|
Install Docker Compose from the tutorial <https://docs.docker.com/compose/install/>.</br>
|
||
|
Get the latest project clone to your computer:
|
||
|
```bash
|
||
|
$ git clone https://github.com/huchenw/django-docker.git
|
||
|
```
|
||
|
Run docker-compose commands to start containers:
|
||
|
```bash
|
||
|
$ docker-compose up -d
|
||
|
```
|
||
|
Now you can access the application at <http://localhost> or <http://192.168.99.100>(Docker Toolbox).</br>
|
||
|
## Static Files
|
||
|
To collect static files for nginx to access, just run:
|
||
|
```bash
|
||
|
$ docker-compose exec web bash
|
||
|
$ python manage.py collectstatic
|
||
|
```
|
||
|
## Django Admin
|
||
|
If you want to access django admin site, please apply the django default migrations to database:
|
||
|
```bash
|
||
|
$ docker-compose exec web bash
|
||
|
$ python manage.py migrate
|
||
|
```
|
||
|
Then you need to create a superuser account:
|
||
|
```bash
|
||
|
$ python manage.py createsuperuser
|
||
|
$ ...
|
||
|
```
|
||
|
## Celery Results
|
||
|
Redis is used as broker for Celery <http://docs.celeryproject.org/en/latest/getting-started/brokers/redis.html>.</br>
|
||
|
The official tutorial <http://docs.celeryproject.org/en/latest/django/> tells us how to use Celery with Django.</br>
|
||
|
You can check the Celery results from logs:
|
||
|
```bash
|
||
|
$ docker-compose logs celery
|
||
|
```
|
||
|
## Docker Images Reference
|
||
|
|
||
|
| Name | Image |
|
||
|
| ------ | ---------------------------------- |
|
||
|
| Nginx | <https://hub.docker.com/_/nginx/> |
|
||
|
| MySQL | <https://hub.docker.com/_/mysql/> |
|
||
|
| Redis | <https://hub.docker.com/_/redis/> |
|
||
|
| Python | <https://hub.docker.com/_/python/> |
|
||
|
|