- Download the Docker compose package:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
- Test the installation:
docker-compose --version
- Building your new image using your Dockerfile:
docker build -t my-django-image:your-image-tag .
- Open your docker-compose.yml file and change the 'XX' to your corresponding port. Also change 'YOUR_USER' with your UNIX username:
version: '3'
services:
web:
build: .
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
container_name: "djangoXX"
volumes:
- "/home/YOUR_USER/django/library:/usr/src/django/library"
ports:
- "90XX:8000"
- Using docker-compose in order to deploy your container:
docker-compose up
- Create a new virtual environment:
python -m venv django_env
- Use this virtual env:
source ./django_env/bin/activate
- Install dependencies:
pip install django
pip install django_rest_framework
- Create a new project:
django-admin startproject library
- Create a new application of the project:
django-admin startapp editorial
- Run your migrations:
python manage.py migrate
- Add your application to the INSTALLED_APPS section:
# settings.py
INSTALLED_APPS = [
...
'rest_framework',
'editorial'
]
- Create the files serializers.py and urls.py inside library/editorial directory:
cd library/editorial
touch serializers.py urls.py
<<<<<<< HEAD
(DB normalization)[https://www.guru99.com/database-normalization.html]
postgres