Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Latest commit

 

History

History
106 lines (87 loc) · 5.61 KB

deploy_notes_docker.md

File metadata and controls

106 lines (87 loc) · 5.61 KB
  1. Open a Command Prompt / Terminal / Shell, either:

    1. On your local computer / localhost
    2. Or, if you develop on a remote server then SSH into the remote machine.
  2. Execute the following commands:

    1. (Optional) For Production or Remote Servers Only
      1. sudo useradd usernamehere -s /bin/bash && passwd usernamehere
      2. sudo mkdir /home/usernamehere/public_html && chown -Rf usernamehere:groupnamehere /home/usernamehere/public_html
    2. (Optional) Install Git on your operating system, assuming you don't already have it installed:
      1. RedHat / CentOS / Fedora: sudo update yum && sudo yum install git
      2. Ubuntu / Debian: sudo apt-get update && sudo apt-get install git
      3. Mac: sudo brew install git
    3. cd to change the directory to where you want the git repository / application to be downloaded
    4. Clone the GitHub repository
      1. Using the SSH protocol: git clone git@github.com:codeforgreenville/upstate_tech_cal_service.git
      2. Or, using the HTTPS protcol: git clone https://github.com/codeforgreenville/upstate_tech_cal_service.git
    5. cd upstate_tech_cal_service
    6. Install Docker and Docker Compose on your operating system: https://docs.docker.com/compose/install/
      1. Alternatively, install Docker Desktop: https://docs.docker.com/desktop/
  3. Create a local config.ini file, if one does not exist. 3. cp config.ini.example-docker config.ini && nano config.ini 4. Fill in the placeholder values in your config.ini with the real values for the following, nano config.ini 1. Register your own Eventbrite token 2. Flask secret can be any long random string 3. (No longer needed) Version 3 of the Meetup.com API requires an Oauth Key. However, as of Oct 2019, we're using only public GET API endpoints that require not authentication. It's not necessary to register a Meetup.com API key unless/until the app needs access to an authenticated endpoint, at which point the key could be added to the config file

  4. Create a local logging_config.ini file

    1. cp logging_config.ini.example logging_config.ini
    2. mkdir logs
  5. Test with gunicorn WSGI Server on a localhost port

    1. Run the following to generate / update the all_meetings.json file in your application directory.
    2. docker-compose up --build or docker-compose up -d --build to run the container in detatched mode
    3. View logs with docker-compose logs or follow logs with docker-compose logs -f
    4. Visit the localhost application in your web browser, and see if it works: http://127.0.0.1:8000/api/gtc?tags=1
  6. (Optional) On Remote or Production Servers - Setup a cronjob to generate the all_meetings.json, for example, at :35 after every hour

    1. crontab -e -u usernamehere
    2. 35 * * * * source $HOME/.bashrc; cd ~/upstate_tech_cal_service && docker-compose restart
  7. (Optional) Configure hosting via a real Web Server, like Apache or Nginx

    1. Configure an Nginx or Apache to "talk" to the container via the respective "proxy" directive(s)
      1. Apache Example
       <VirtualHost *:443>
      
       UseCanonicalName On
      
       ServerName events.openupstate.org
      
       DocumentRoot /home/eventapi/public_html
       DirectoryIndex index.html
       ErrorLog /var/log/httpd/events.openupstate.org_error_log
       CustomLog /var/log/httpd/events.openupstate.org_access_log combined
      
       ProxyPass /api/ http://127.0.0.1:8000|http://events.openupstate.org/api/
      
       <Directory /home/eventapi/public_html>
       	Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
       	allow from all
      
       	AllowOverride None
       	Include /home/eventapi/public_html/.htaccess
       </Directory>
      
       # HSTS to force browsers to always ask for https
       Header always set Strict-Transport-Security "max-age=31536000;"
      
       SSLCertificateFile /etc/letsencrypt/live/events.openupstate.org/fullchain.pem
       SSLCertificateKeyFile /etc/letsencrypt/live/events.openupstate.org/privkey.pem
       Include /etc/letsencrypt/options-ssl-apache.conf
       </VirtualHost>
      
    2. Nginx Virtual Host Example - modified from Boban, and not tested
      server {
      	server_tokens off;
      	listen      443 ssl;
      	server_name         events.openupstate.org;
      
      	ssl_certificate     /etc/letsencrypt/live/events.openupstate.org/fullchain.pem;
      	ssl_certificate_key /etc/letsencrypt/live/events.openupstate.org/privkey.pem;
      
      	access_log      /var/log/nginx/access.myserver.log;
      	error_log       /var/log/nginx/error.myserver.log;
      
      	location /api {
      		include proxy_params;
      		proxy_pass http://127.0.0.1:8000;
      	}
      }
      
    3. If hosting Nginx or Apache through a Docker container on the same Docker network, you can replace 127.0.0.1 with the container name, and remove the 127.0.0.1:8000 port mapping in docker-compose.yml.

Kudos To