forked from ubccr/coldfront
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from ucb-rit/develop
v3.4.0 Changes
- Loading branch information
Showing
95 changed files
with
2,810 additions
and
1,302 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Environment variables used by Docker (specifically for docker-compose.yml) | ||
DB_NAME=cf_brc_db | ||
COLDFRONT_PORT=8880 |
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
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,34 +1,33 @@ | ||
FROM centos:8 | ||
FROM centos/python-38-centos7 | ||
|
||
LABEL description="coldfront" | ||
|
||
# install dependencies | ||
RUN yum -y install epel-release | ||
RUN yum -y update | ||
RUN yum -y install python36 python36-devel git memcached redis | ||
|
||
USER root | ||
WORKDIR /root | ||
|
||
# install coldfront | ||
RUN mkdir /opt/coldfront_app | ||
|
||
WORKDIR /opt/coldfront_app | ||
|
||
RUN cd /opt/coldfront_app | ||
RUN git clone https://github.com/ubccr/coldfront.git | ||
RUN python3.6 -mvenv venv | ||
RUN source venv/bin/activate | ||
|
||
WORKDIR /opt/coldfront_app/coldfront | ||
|
||
RUN cd /opt/coldfront_app/coldfront | ||
RUN pip3 install wheel | ||
RUN pip3 install -r requirements.txt | ||
RUN cp coldfront/config/local_settings.py.sample coldfront/config/local_settings.py | ||
RUN cp coldfront/config/local_strings.py.sample coldfront/config/local_strings.py | ||
|
||
RUN python3 ./manage.py initial_setup | ||
RUN python3 ./manage.py load_test_data | ||
|
||
EXPOSE 8000 | ||
COPY requirements.txt ./ | ||
RUN pip install -r requirements.txt && rm requirements.txt | ||
RUN pip install jinja2 pyyaml | ||
|
||
# mybrc or mylrc | ||
ARG PORTAL="mybrc" | ||
RUN mkdir -p /var/log/user_portals/cf_${PORTAL} \ | ||
&& touch /var/log/user_portals/cf_${PORTAL}/cf_${PORTAL}_{portal,api}.log \ | ||
&& chmod 775 /var/log/user_portals/cf_${PORTAL} \ | ||
&& chmod 664 /var/log/user_portals/cf_${PORTAL}/cf_${PORTAL}_{portal,api}.log | ||
|
||
COPY . /vagrant/coldfront_app/coldfront/ | ||
WORKDIR /vagrant/coldfront_app/coldfront/ | ||
|
||
RUN chmod +x ./manage.py | ||
|
||
CMD ./manage.py initial_setup \ | ||
&& ./manage.py add_accounting_defaults \ | ||
&& ./manage.py add_allowance_defaults \ | ||
&& ./manage.py add_directory_defaults \ | ||
&& ./manage.py create_allocation_periods \ | ||
&& ./manage.py create_staff_group \ | ||
&& ./manage.py collectstatic --noinput \ | ||
&& ./manage.py runserver 0.0.0.0:80 | ||
|
||
EXPOSE 80 | ||
STOPSIGNAL SIGINT |
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,5 @@ | ||
FROM postgres:15 | ||
|
||
LABEL description="coldfront db" | ||
|
||
RUN apt update && apt install -y sudo postgresql-client |
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 |
---|---|---|
|
@@ -46,28 +46,34 @@ of variables used by Ansible to configure the system. | |
``` | ||
cp bootstrap/ansible/main.copyme main.yml | ||
``` | ||
7. Customize `main.yml`. In particular, uncomment everything under the `dev_settings` section, and fill in the below variables. Note | ||
7. Generate a key to be used as the `SECRET_KEY` for Django. | ||
``` | ||
# This produces two lines: condense them into one. | ||
openssl rand -base64 64 | ||
``` | ||
8. Customize `main.yml`. In particular, uncomment everything under the `dev_settings` section, and fill in the below variables. Note | ||
that quotes need not be provided, except in the list variable. | ||
``` | ||
django_secret_key: secret_key_from_previous_step | ||
db_admin_passwd: password_here | ||
redis_passwd: password_here | ||
from_email: [email protected] | ||
admin_email: [email protected] | ||
email_admin_list: ["[email protected]"] | ||
request_approval_cc_list: ["[email protected]"] | ||
``` | ||
8. Provision the VM. This should run the Ansible playbook. Expect this to take | ||
9. Provision the VM. This should run the Ansible playbook. Expect this to take | ||
a few minutes on the first run. | ||
``` | ||
vagrant up | ||
``` | ||
9. SSH into the VM. | ||
10. SSH into the VM. | ||
``` | ||
vagrant ssh | ||
``` | ||
10. On the host machine, navigate to `http://localhost:8880`, where the | ||
11. On the host machine, navigate to `http://localhost:8880`, where the | ||
application should be served. | ||
11. (Optional) Load data from a database dump file. | ||
12. (Optional) Load data from a database dump file. | ||
``` | ||
# Clear the Django database to avoid conflicts. | ||
python manage.py sqlflush | python manage.py dbshell | ||
|
@@ -207,6 +213,15 @@ multiple files or directories to omit. | |
- Open `htmlcov/index.html` in a browser to view which lines of | ||
code were covered by the tests and which were not. | ||
## Docker - Quick Install (Recommend) | ||
1. Generate configuration (`dev_settings.py`): have Python with the `jinja2` and `pyyaml` libraries installed, and then run `bootstrap/development/gen_config.sh` | ||
2. Build Images: In the base directory, run `docker build . -t coldfront` and `docker build . -f Dockerfile.db -t coldfront_db`. `--build-arg PORTAL=mylrc` can be added to the build command to build for mylrc. | ||
3. If needed, modify `.env` to customize the web server port and the database name (e.g from `cf_mybrc_db` to `cf_mylrc_db`) | ||
4. To run: In the base directory, run `docker compose up` | ||
5. To enter the coldfront container (similar to `vagrant ssh`): run `docker exec -it coldfront-coldfront-1 bash` | ||
6. To load a database backup: run `bootstrap/development/docker_load_database_backup.sh ${DB_NAME} ${PATH_TO_DUMP}` | ||
7. To start from scratch (delete volumes): In the base directory, run `docker compose down --volumes` | ||
## Local Machine - Quick Install (Not Recommended) | ||
1. ColdFront requires Python 3.6, memcached, and redis. | ||
|
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
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
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,4 @@ | ||
#!/bin/bash | ||
# $1 = database name | ||
# $2 = dump file | ||
docker exec -i coldfront-db-1 pg_restore --verbose --clean -U admin -d $1 < $2 |
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,14 @@ | ||
#!/usr/bin/env bash | ||
cp coldfront/config/local_settings.py.sample \ | ||
coldfront/config/local_settings.py | ||
cp coldfront/config/local_strings.py.sample \ | ||
coldfront/config/local_strings.py | ||
python -c \ | ||
"from jinja2 import Template, Environment, FileSystemLoader; \ | ||
import yaml; \ | ||
env = Environment(loader=FileSystemLoader('bootstrap/ansible/')); \ | ||
env.filters['bool'] = lambda x: str(x).lower() in ['true', 'yes', 'on', '1']; \ | ||
options = yaml.safe_load(open('main.yml').read()); \ | ||
options.update({'redis_host': 'redis', 'db_host': 'db'}); \ | ||
print(env.get_template('settings_template.tmpl').render(options))" \ | ||
> coldfront/config/dev_settings.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
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
Oops, something went wrong.