From e5d471aeed2429cfd26a4085c42136a3761fd2c7 Mon Sep 17 00:00:00 2001 From: sina lalehbakhsh Date: Wed, 10 Jul 2024 07:06:52 -0400 Subject: [PATCH] Add All Changes --- .../Setup Docker On VPS.txt | 5 ++ ...ffline steps to run docker-compose-yml.txt | 53 +++++++++++++++++++ ...online steps to run docker-compose-yml.txt | 1 + docker-compose.yml | 4 +- docker-compose.ymloffline | 30 +++++++++++ docker-compose.ymlonline | 30 +++++++++++ 6 files changed, 121 insertions(+), 2 deletions(-) rename Setup Docker On VPS.txt => Steps /Setup Docker On VPS.txt (83%) create mode 100644 Steps /offline steps to run docker-compose-yml.txt create mode 100644 docker-compose.ymloffline create mode 100644 docker-compose.ymlonline diff --git a/Setup Docker On VPS.txt b/Steps /Setup Docker On VPS.txt similarity index 83% rename from Setup Docker On VPS.txt rename to Steps /Setup Docker On VPS.txt index a83e562..734e81a 100644 --- a/Setup Docker On VPS.txt +++ b/Steps /Setup Docker On VPS.txt @@ -13,3 +13,8 @@ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker- sudo chmod +x /usr/local/bin/docker-compose +docker pull python:3.10 + +docker pull postgres:14 + +docker pull nginx:latest \ No newline at end of file diff --git a/Steps /offline steps to run docker-compose-yml.txt b/Steps /offline steps to run docker-compose-yml.txt new file mode 100644 index 0000000..0247ac4 --- /dev/null +++ b/Steps /offline steps to run docker-compose-yml.txt @@ -0,0 +1,53 @@ +##### Option 1: Adjust System Settings + +## Open the sysctl.conf file: +sudo nano /etc/sysctl.conf + + + +## Add the following line to allow non-root users to bind to port 443: +net.ipv4.ip_unprivileged_port_start=443 + + +## Save the file and exit the editor. + + +## Reload the sysctl configuration: +sudo sysctl -p + + + +##### Option 2: Use Ports Above 1024 + +## Updated docker-compose.yml: + +version: '3.9' + +services: + web: + build: . + command: sh -c "python manage.py makemigrations && python manage.py migrate && gunicorn myproject.wsgi:application --bind 0.0.0.0:8000" + volumes: + - .:/code + ports: + - "8000:8000" + expose: + - "8000" + env_file: + - .env + + nginx: + image: nginx:latest + ports: + - "8080:80" + - "8443:443" + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./certs:/etc/nginx/certs:ro + depends_on: + - web + + db: + image: postgres:14 + environment: + - "POSTGRES_HOST_AUTH_METHOD=trust" diff --git a/Steps /online steps to run docker-compose-yml.txt b/Steps /online steps to run docker-compose-yml.txt index 37118bb..43a3eb7 100644 --- a/Steps /online steps to run docker-compose-yml.txt +++ b/Steps /online steps to run docker-compose-yml.txt @@ -1,6 +1,7 @@ FOR FIRST TIME to Run in fresh VPS + sudo apt install certbot certbot certonly --standalone --agree-tos --register-unsafely-without-email -d sina.sinalalehbakhsh.monster -v diff --git a/docker-compose.yml b/docker-compose.yml index a636f44..4cb4c5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,8 @@ services: nginx: image: nginx:latest ports: - - "80:80" - - "443:443" + - "8080:80" + - "8443:443" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./certs:/etc/nginx/certs:ro diff --git a/docker-compose.ymloffline b/docker-compose.ymloffline new file mode 100644 index 0000000..4cb4c5e --- /dev/null +++ b/docker-compose.ymloffline @@ -0,0 +1,30 @@ +version: '3.9' + +services: + web: + build: . + command: sh -c "python manage.py makemigrations && python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:8000" + volumes: + - .:/code + ports: + - "8000:8000" + expose: + - "8000" + env_file: + - .env + + nginx: + image: nginx:latest + ports: + - "8080:80" + - "8443:443" + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./certs:/etc/nginx/certs:ro + depends_on: + - web + + db: + image: postgres:14 + environment: + - "POSTGRES_HOST_AUTH_METHOD=trust" diff --git a/docker-compose.ymlonline b/docker-compose.ymlonline new file mode 100644 index 0000000..a636f44 --- /dev/null +++ b/docker-compose.ymlonline @@ -0,0 +1,30 @@ +version: '3.9' + +services: + web: + build: . + command: sh -c "python manage.py makemigrations && python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:8000" + volumes: + - .:/code + ports: + - "8000:8000" + expose: + - "8000" + env_file: + - .env + + nginx: + image: nginx:latest + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./certs:/etc/nginx/certs:ro + depends_on: + - web + + db: + image: postgres:14 + environment: + - "POSTGRES_HOST_AUTH_METHOD=trust"