Skip to content

Unichallenge/UniChannel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniChannel Logo

Welcome to the UniChannel project! Feel free to browse around the source code, snd remember, all Pull Request and Issues are welcome!

TODOs

  • Create some TODOs.
  • Fix grid system for posts.
  • Fix all fields starting as red in submission form (use a FormGroup).
  • Allow optional image upload in submission form.
  • Output all posts as RSS.
  • Ensure no Referer leaks to post links.
  • Enable indexing. (@chrisagelou)

Good to have:

  • Fix and reintroduce notification system.

Development

To setup your development environment, after cloning, do:

cd app
# Setup the Angular application
npm install
cd ..

# Setup the Django app
cd server
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

You will also need to populate your server/unichallenge/site_config.py file with:

  • The database connection information about your local MySQL installation.
  • The Firebase configuration for your app.
  • the DEBUG = True flag, to indicate this is a dev environment.

You should also most probably run all migrations and create a superuser:

cd server;
python manage.py migrate
python manage.py createsuperuser

After all this, you can simply run these commands (in seperate terminals):

cd server; source venv/bin/activate; python manage.py runserver
cd app; npm run start

And voila! The app is now running at http://localhost:4200!

Production

Deploy the app

To deploy the app, run while in its directory:

fab -H deployer@<host> deploy

The script will take care of building the images, running any pending migrations and (re)starting the apps.

Setup the app

Ensure Docker, Docker Compose, Python >3.6 and Fabric >2 are installed.

Using the root user, execute:

# Or substitute with your own directory
mkdir /usr/unichannel
# Create the unichannel user
useradd unichannel
# Create the deployer user
useradd deployer
# Make unichannel the owner
chown -R unichannel:unichannel /usr/unichannel
# Allow the deployer to run Docker commands and access the new directory
usermod -a -G docker deployer
usermod -a -G unichannel deployer

Now using the unichannel user:

# Initialize the repository
cd /usr/unichannel
git clone git@github.com:Unichallenge/unichannel.git

# Create the user SSH keys and allow other users to make deploys
cd
ssh-keygen
mkdir .ssh; chmod 700 .ssh
cat > .ssh/authorized_keys

The .ssh/authorized_keys file should have the following format:

command="cd /usr/unichannel; fab $SSH_ORIGINAL_COMMAND",no-pty ssh-rsa # ...

This will ensure people with deploy access can only execute fabric tasks.

Next up, create the /usr/unichannel/unichannel directory and place the firebase.json private key file you generated from Firebase. More about how to create it here.

You must also create the /usr/unichannel/.env file containing all the environment variables necessary for your application to run. This should contain the following:

  • UID = The UID of the unichallenge user.
  • GID = The GID of the unichallenge user.
  • MARIA_PASS = A unique password for your MariaDB installation.
  • SENTRY_DSN = The Sentry DSN for error logging.

Compose will automatically take these into consideration when setting up its environment.

You can now try and deploy the app itself!