-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete changelog: * Added Push notifications * Added RSS-based post sources * Added new fields to posts * Revamped the administration interface and its features * Added Sentry for error reporting * Added new deployment system; see README
- Loading branch information
Spyridon Pagkalos
committed
Sep 16, 2019
1 parent
7dcb84b
commit 53dadc2
Showing
539 changed files
with
15,266 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
unichallenge_client/node_modules | ||
/app | ||
/venv | ||
/unichannel | ||
/.env | ||
/.gitignore | ||
/fabfile.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
# Editor stuff | ||
.idea | ||
.vscode | ||
.env | ||
node_modules | ||
*.iml | ||
|
||
# Python configs | ||
site_config.py | ||
/database.py | ||
/venv | ||
|
||
# Django stuff: | ||
/unichallenge_server/db.sqlite3 | ||
# Development assets | ||
*.sqlite3 | ||
firebase.json | ||
unichannel | ||
app/static | ||
|
||
# Environments | ||
/unichallenge_server/venv/ | ||
# Inline configuration | ||
site_config.py | ||
|
||
# For b4s | ||
/unichallenge_server/djuc/__pycache__/ | ||
/unichallenge_server/djuc/*.py[cod] | ||
/unichallenge_server/djuc/migrations/__pycache__/ | ||
# Node dependencies | ||
node_modules | ||
|
||
# For project_site | ||
/unichallenge_server/unichallenge/__pycache__/ | ||
/unichallenge_server/unichallenge/*.py[cod] | ||
# Python stuff | ||
venv | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
FROM node | ||
FROM python | ||
|
||
RUN mkdir /angular | ||
WORKDIR /angular | ||
COPY unichallenge_client/package.json /angular | ||
COPY unichallenge_client/package-lock.json /angular | ||
RUN npm install | ||
COPY unichallenge_client /angular | ||
RUN npm run prod | ||
WORKDIR /app | ||
COPY server/requirements.txt . | ||
|
||
FROM nginx | ||
RUN pip install -r requirements.txt | ||
RUN pip install uwsgi | ||
|
||
COPY --from=0 /angular/dist/uknow /files/angular | ||
COPY unichallenge_server/static /files/static | ||
COPY server . | ||
COPY server/unichallenge/site_config.production.py unichallenge/site_config.py | ||
|
||
CMD uwsgi --socket 0.0.0.0:8000 --protocol uwsgi --module unichallenge.wsgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
|
||
# UniChannel | ||
|
||
## Development | ||
|
||
To setup your development environment, after cloning, do: | ||
|
||
```bash | ||
cd app | ||
# Setup the Angular application | ||
npm install | ||
cd .. | ||
|
||
# Setup the Django app | ||
cd server | ||
virtualenv | ||
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: | ||
|
||
```bash | ||
cd server; | ||
python manage.py migrate | ||
python manage.py createsuperuser | ||
``` | ||
|
||
After all this, you can simply run these commands (in seperate terminals): | ||
|
||
```bash | ||
cd server; source venv/bin/activate; python manage.py runserver | ||
cd app; yarn run serve | ||
``` | ||
|
||
And **voila!** The app is now running at [http://localhost:4200](http://localhost:4200)! | ||
|
||
## Production | ||
|
||
### Deploy the app | ||
|
||
To deploy the app, run while in its directory: | ||
|
||
```bash | ||
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: | ||
|
||
```bash | ||
# 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: | ||
|
||
```bash | ||
# Initialize the repository | ||
cd /usr/unichannel | ||
git clone [email protected]: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: | ||
|
||
```bash | ||
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](https://firebase.google.com/docs/admin/setup#initialize_the_sdk). | ||
|
||
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
server { | ||
server_name channel.unichallenge.gr; | ||
listen 80; | ||
|
||
location /api { | ||
uwsgi_pass server:8000; | ||
uwsgi_pass uwsgi:8000; | ||
include /etc/nginx/uwsgi.conf; | ||
} | ||
|
||
location /admin { | ||
uwsgi_pass server:8000; | ||
uwsgi_pass uwsgi:8000; | ||
client_max_body_size 20M; | ||
include /etc/nginx/uwsgi.conf; | ||
} | ||
|
||
location /media { | ||
root /files; | ||
location /static/ { | ||
root /static/; | ||
try_files $uri $uri/ =403; | ||
} | ||
|
||
location /static { | ||
root /files; | ||
location /media/ { | ||
root /static/; | ||
try_files $uri $uri/ =403; | ||
} | ||
|
||
location / { | ||
root /files/angular; | ||
root /static/; | ||
index index.html; | ||
try_files $uri$args $uri$args/ /index.html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
uwsgi_param QUERY_STRING $query_string; | ||
uwsgi_param REQUEST_METHOD $request_method; | ||
uwsgi_param CONTENT_TYPE $content_type; | ||
uwsgi_param CONTENT_LENGTH $content_length; | ||
uwsgi_param REQUEST_URI $request_uri; | ||
uwsgi_param PATH_INFO $document_uri; | ||
uwsgi_param DOCUMENT_ROOT $document_root; | ||
uwsgi_param SERVER_PROTOCOL $server_protocol; | ||
uwsgi_param REMOTE_ADDR $remote_addr; | ||
uwsgi_param REMOTE_PORT $remote_port; | ||
uwsgi_param SERVER_ADDR $server_addr; | ||
uwsgi_param SERVER_PORT $server_port; | ||
uwsgi_param SERVER_NAME $server_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM node | ||
|
||
WORKDIR /app | ||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
RUN npm install | ||
|
||
COPY src . | ||
COPY angular.json . | ||
COPY proxy.conf.json . | ||
COPY tsconfig.json . | ||
COPY tslint.json . | ||
|
||
RUN npm run prod | ||
|
||
FROM nginx | ||
|
||
COPY --from=0 /app/dist /static/ | ||
COPY static /static/static | ||
COPY .nginx.server.conf /etc/nginx/conf.d/default.conf | ||
COPY .uwsgi.conf /etc/nginx/uwsgi.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.