This will setup, using docker-compose, a basic Django + DRF + Vuejs (vue-cli project) project.
- Ready to be used for development (hot reload, etc)
- Ready to be used on Production (nginx conf, prod settings, etc)
Start (and build if needed) containers with the command:
docker-compose up --build
Create Django tables on DB:
docker-compose run backend migrate
Create super user:
docker-compose run backend createsuperuser
Start all containers:
docker-compose up
First, be sure to complete First steps (described above).
Then, after you start all containers (with docker-compose up, you are free to start coding the backend or frontend (the code will be auto-reloaded, both
the backend and frontend, each time you save the files in your editor).
Please fill a bug :)
- File
docker-compose.yml: Orchestrate all containers settings - Directory
dockerfiles:- File
backend: Dockerfile to setup Django + DRF - File
vuejs: Dockerfile to setup Vuejs + Webpack + NPM + etc...
- File
- File
PipfileandPipfile.lock: Pipenv files - File
README.md: You are here :) - Directory
src:- Directory
backend: Here is the Django + DRF project. - Drirectory
frontend: Here is the Vuejs project.
- Directory
DRF container uses python:latest (more info at https://hub.docker.com/_/python/. To know which version is running on the container, run: docker-compose run backend python --version
Question: Can i run
manage.pyscripts from my host? Iftrue, how?
-
Answer: Yes you can. Just remember to start your commands with:
docker-compose run backend <any manage.py option here>So for example, if you want to get
manage.pyhelp, you would write:docker-compose run backend helpLets suppose you want to list the migrations, you would write:
docker-compose run backend showmigrationsAnother example, if you want to get a
pythonshell (commandpython manage.py shell), you would write:docker-compose run backend shell
Question: Can i run
django-adminscript from my host? Iftrue, how?
-
Answer: Yes you can. Just remember to start your commands with:
docker-compose run backend django-admin <your options here>So for example, to get
django-adminhelp, you would write:docker-compose run backend django-admin helpAnother example, if you want to get a
db shell, you would write:docker-compose run backend django-admin dbshell
Question: How can i create a django app?
-
Answer: Just use the command:
docker-compose run backend startapp <your app name here>You will found the recently created app inside
src/backend
Question: Do i need to install requirements locally on my system?
- Answer: Not if you dont want. As described above, you should be able to excecute all django commands as described above.
- Install
pipenvwith your distro package manager, or as you prefer. - In the same directory where
PipfileandPipfile.lockexists, run:pipenv install - Done, now you are able to add your bugs at
src/backend
- Create a directory where
npm i -g ...will be installed. Run:mkdir ~/.npm-global - Let
npmwhere to find installed packages. Run:npm config set prefix '~/.npm-global' - Let your
bashknows whereexcecutableinstalled bynpmare. Run:echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.bashrc. Apply changes made on$PATHrunning:source ~/.bashrc, or open a new terminal. - Install
@vue-cli, run:npm install -g @vue/cli - Install
@vue/cli-init, run:npm install -g @vue/cli-init