Skip to content

matplo/fod

 
 

Repository files navigation

Dockerizing Flask with Postgres, Gunicorn, and Nginx

Startup

  • make sure to put your certificates in ./certificates
-rw-r--r--  cert.pem
-rw-------  privkey.pem
  • then
. ./init.sh
prod.sh up prod build
  • visit: https://localhost

  • hint: use tab after typing prod.sh - some predefined util scripts/commands available

    • for example: prod.sh hot_update puts things into web image and restarts it - updates available pronto

Renew certificates - quick

enable port 80 in the nginx

  • edit the nginx configuration in .yml
nginx:
  build: ./services/nginx
  volumes:
    - ./certificates:/etc/nginx/ssl
    - static_volume:/home/app/web/project/static
    - media_volume:/home/app/web/project/media
    - pages_volume:/home/app/web/project/pages
    - templates_volume:/home/app/web/project/templates
  ports:
    - 80:80  # Added to enable HTTP challenge
    - 443:443
  depends_on:
    - web

restart

  • fod restart

run certbot (host)

  • then in the host (not within docker):
sudo certbot certonly --standalone -d yourdomain.com
  • note, you may need to install certbot
sudo apt update
sudo apt install certbot python3-certbot-nginx

copy the new certificates

  • copy the certs where they belong (from /etc/letsencrypt/live in your host; note will need root priv; remember chown then...)
cp /etc/letsencrypt/live/<yourdomain.com>/cert.pem <wherefod>/fod/certificates/
cp /etc/letsencrypt/live/<yourdomain.com>/privkey.pem <wherefod>/fod/certificates/
  • note, you may want to use .../fullchain.pem as cert.pem for .../fod/certificates/ and/or modify the services/nginx/nginx.conf

disable the port 80

  • disable the 80:80 in the .yml file

restart

  • fod restart

About

Flask + Docker

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 51.4%
  • Shell 27.6%
  • HTML 20.1%
  • Dockerfile 0.9%