-
Notifications
You must be signed in to change notification settings - Fork 5
Setting up an environment on the server
If you don't want to set up a full stack on your own computer (instructions here), then developing on the server is a viable alternative. It is also useful for testing your changes in the dev environment (which uses a copy of the production database) before pushing them to production.
git clone https://github.com/VenerableHouse/VenerableWebsite ~/VenerableWebsite
See setting up an environment locally for why a virtualenv is recommended.
mkdir ~/virtualenvs && cd ~/virtualenvs
virtualenv ruddweb
source ~/virtualenvs/ruddweb/bin/activate
cd ~/VenerableWebsite
pip install -r requirements.txt
python run_server.py --port 5000 --env (dev|test|prod)
When running Flask's built in test server, you can only connect to it from localhost (don't change this; opening up the test server to the internet is a huge security risk!). To get around this, you will need to do port forwarding:
ssh -L 9001:localhost:5000 <host>
Then, when you make a request to localhost:9001 on your own computer, it forwards the request to the host's localhost:5000 port. So if the Flask application is listening on port 5000 (the default), then browsing localhost:9001 on your computer will send requests to the test application.
In the past you may have used a 'shared' folder to edit files located on a virtual machine from your normal development environment. A similar setup can be performed to edit your server directory locally. You'll need to install sshfs. Create a local mountpoint
directory to mirror the remote directory. Then mount the remote directory with:
sshfs [email protected]/ mountpoint
(this assumes that you have the VenerableWebsite repo cloned on your server directory).
At the end of your development session you can unmount with:
umount mountpoint