source : https://londonappdeveloper.com/django-docker-deployment-with-https-using-letsencrypt/
Run new project with docker-compose called app in current directory
- "--rm" removes the container after running
- ""sh -c" runs the command in the container
- "django-admin startproject app ." creates a new project called app in the current directory
docker-compose run -rm app sh -c "django-admin startproject app ."
Run docker-compose up
- "-d" runs the container in the background
docker-compose up -d
Create a new app in the project
docker-compose run --rm app sh -c "python manage.py startapp home"
Update docker-compose.yml with environment variables
vim docker-compose.yml
Create a new EC2 instance
- Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
- t2.micro
- Enable Auto-assign Public IP
sudo yum update -y
#sudo amazon-linux-extras install -y docker
# install docker
sudo yum install docker -y
# start docker service
sudo systemctl enable docker.service
sudo systemctl start docker.service
# add ec2-user to docker group
sudo usermod -a -G docker ec2-user # give ec2-user permission to run docker commands
# Install Docker Compose
wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Install Git
sudo yum install -y git
# Check versions of docker and docker-compose
docker --version
docker-compose --version
docker run hello-world # test docker installation
# Clone the project
# generate ssh key to connect to github
ssh-keygen -t ed25519 -C "Github deploy SSH Key" # generate ssh key
#ssh-keygen -t rsa -b 4096 -C "
# delete a folder
rm -rf folder_name
# Generate the SSL initial certificates
docker-compose -f docker-compose.deploy.yml run --rm certbot /opt/certify-init.sh
cp .env.sample .env
vi .env
DJANGO_SECRET_KEY=realsecretkeyaodazkndazqsd,ad144688766
ACME_CHALLENGE=thomas.awounfouet@gmaiL.com
DOMAIN=app.awf-digital.com
# Rename a folder
mv old_folder_name new_folder_name
mv cerbot/ certbot/