Last active
July 24, 2024 02:54
-
-
Save osw4l/cbfbfb3f7a7f42ab31fa5083b358f316 to your computer and use it in GitHub Desktop.
deploy django-osw4l 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo su - | |
# update so | |
sudo apt update | |
sudo apt upgrade | |
# install curl | |
sudo apt install curl | |
#install docker-compose via curl | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
# install docker-compose via apt-get | |
sudo apt-get install docker-compose | |
# check docker compose version | |
docker–compose –version | |
# install nginx | |
sudo apt install nginx | |
git clone repo | |
cd repo | |
# create environment file and updateit | |
cp .env_template .env | |
# edit with nano and change DJANGO_PRODUCTION from false to true | |
# then press ctrl + o to save and ctrl + x to exit | |
nano .env | |
# build image | |
docker-compose build | |
# up image | |
docker-compose up -d | |
# create migrations | |
docker-compose exec backend python3 manage.py migrate | |
# restart celery beat | |
docker-compose restart beat | |
# create superuser | |
docker-compose exec backend python3 manage.py createsuperuser | |
# collect statics, run this to go inisde the backend container | |
docker-compose run -u root backend bash | |
# run this when you're inside, and then press ctrl + d to get back | |
python3 manage.py collectstatic --noinput | |
# go to nginx | |
cd /etc/nginx/sites-enabled | |
# remove old default file | |
rm default | |
# create new config file | |
touch mysite | |
# update with nano, copy all the content of nginx.conf inside, then save it press | |
# press ctrl + o to save changes and ctrl + x to exit | |
nano mysite | |
# restart nginx | |
services nginx restart | |
# go to mysite.com and enjoy it ;) | |
# if you want add ssl, just follow the next instructions | |
# You'll need to add the Certbot PPA to your list of repositories. | |
# To do so, run the following commands on the command line on the machine: | |
sudo apt-get update | |
sudo apt-get install software-properties-common | |
sudo add-apt-repository universe | |
sudo add-apt-repository ppa:certbot/certbot | |
sudo apt-get update | |
# Install Certbot | |
sudo apt-get install certbot python-certbot-nginx | |
# Install Certbot | |
sudo apt-get install certbot python-certbot-nginx | |
# Run this command to get a certificate and have Certbot edit your Nginx | |
# configuration automatically to serve it, turning on HTTPS access in a single step. | |
sudo certbot --nginx | |
# restart nginx, again | |
services nginx restart | |
# go to agan mysite.com , now it have ssl and enjoy it agai ;) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name mysite.com; | |
location / { | |
proxy_pass http://localhost:3002; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_cache_bypass $http_upgrade; | |
} | |
location /static { | |
rewrite (.*) $1 break; | |
proxy_pass http://127.0.0.1:3002; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment