Skip to content

Commit c9828df

Browse files
committed
moved migrations out of dockerfile and updated documentation
1 parent 61b0912 commit c9828df

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ ENV PORT=${PORT}
3535
EXPOSE ${PORT}
3636

3737
COPY conditional /opt/conditional/conditional
38-
COPY migrations /opt/conditional/migrations
3938
COPY *.py package.json /opt/conditional
4039
COPY --from=build-frontend /opt/conditional/conditional/static /opt/conditional/conditional/static
4140

README.md

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,103 @@ A comprehensive membership evaluations solution for Computer Science House.
88
Development
99
-----------
1010

11-
To run the application, you must have the latest version of [Python 3](https://www.python.org/downloads/) and [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) installed. Once you have those installed, create a new virtualenv and install the Python dependencies:
11+
### Config
12+
13+
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.env.py` for an example.
1214

15+
#### Add OIDC Config
16+
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth
17+
```py
18+
# OIDC Config
19+
OIDC_ISSUER = "https://sso.csh.rit.edu/auth/realms/csh"
20+
OIDC_CLIENT_CONFIG = {
21+
'client_id': '',
22+
'client_secret': '',
23+
'post_logout_redirect_uris': ['http://0.0.0.0:6969/logout']
24+
}
1325
```
26+
27+
#### Database
28+
You can either develop using the dev database, or use the local database provided in the docker compose file
29+
30+
Using the local database is detailed below, but both options will require the dev database password, so you will have to ask an RTP for this too
31+
32+
### Run (Without Docker)
33+
34+
To run the application without using containers, you must have the latest version of [Python 3](https://www.python.org/downloads/) and [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) installed. Once you have those installed, create a new virtualenv and install the Python dependencies:
35+
36+
```sh
1437
virtualenv .conditionalenv -p `which python3`
1538
source .conditionalenv/bin/activate
1639
pip install -r requirements.txt
17-
export FLASK_APP=app.py
1840
```
1941

20-
In addition, you must have Node, NPM, and Gulp CLI installed to properly execute the asset pipeline. If you don't have Node installed, we recommending installing with [NVM](https://github.com/creationix/nvm):
42+
In addition, you must have Node, NPM, and Weback CLI installed to properly execute the asset pipeline. If you don't have Node installed, we recommending installing with [NVM](https://github.com/creationix/nvm):
2143

22-
```
44+
```sh
2345
nvm install
2446
nvm use
25-
npm install -g gulp
47+
npm install -g webpack
2648
```
2749

28-
Then, install the pipeline and frontend dependencies:
50+
Then, install the pipeline and frontend dependencies: (do this in the `frontend` directory)
2951

30-
```
52+
```sh
3153
npm install
3254
```
3355

34-
### Config
56+
Once you have all of the dependencies installed, run
3557

36-
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.sample.py` for an example.
58+
```sh
59+
npm webpack
60+
```
3761

38-
#### Add OIDC Config
39-
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth
62+
This will build the frontend assets and put them in the correct place for use with flask
63+
64+
Finally, start the flask app with `gunicorn`
65+
66+
```sh
67+
gunicorn
4068
```
41-
# OIDC Config
42-
OIDC_ISSUER = "https://sso.csh.rit.edu/auth/realms/csh"
43-
OIDC_CLIENT_CONFIG = {
44-
'client_id': '',
45-
'client_secret': '',
46-
'post_logout_redirect_uris': ['http://0.0.0.0:6969/logout']
47-
}
69+
70+
or
71+
72+
```sh
73+
python -m gunicorn
4874
```
4975

50-
### Run
76+
### Run (containerized)
5177

52-
Once you have all of the dependencies installed, simply run:
78+
It is likely easier to use containers like `podman` or `docker` or the corresponding compose file
5379

54-
```
55-
npm start
80+
With podman, I have been using
81+
82+
```sh
83+
podman compose up --force-recreate --build
5684
```
5785

58-
This will run the asset pipeline, start the Python server, and start BrowserSync. Your default web browser will open automatically. If it doesn't, navigate to `http://127.0.0.1:3000`. Any changes made to the frontend files in `frontend` or the Jinja templates in `conditional/templates` will cause the browser to reload automatically.
86+
Which can be restarted every time changes are made
5987

6088
### Dependencies
6189

6290
To add new dependencies, add them to `requirements.in` and then run `pip-compile requirements.in` to produce a new locked `requirements.txt`. Do not edit `requirements.txt` directly as it will be overwritten by future PRs.
6391

6492
### Local database
6593

66-
You can run the database locally using the docker compose, make sure to upgrade it as explained below
94+
You can run the database locally using the docker compose
6795

6896
To populate it with dev data for example, you can use the command
6997

70-
```
71-
PGPASSWORD='[DB PASSWORD]' pg_dump -h postgres.csh.rit.edu -p 5432 -U conditional-dev conditional-dev | PGPASSWORD='fancypantspassword' psql -h localhost -p 5432 -U conditional conditional
98+
```sh
99+
PGPASSWORD='[DB PASSWORD]' pg_dump -h postgres.csh.rit.edu -p 5432 -U conditionaldev conditionaldev | PGPASSWORD='fancypantspassword' psql -h localhost -p 5432 -U conditional conditional
72100
```
73101

74102
This can be helpful for changing the database schema
75103

76-
NOTE: to use flask db commands with a database running in the compose file, you will have to update your url to point to localhost, not conditional-postgres
104+
To run migration commands in the local database, you can run the commands inside the docker container. Any migrations created will also be in the local repository since migrations are mounted in the docker compose
105+
```sh
106+
podman exec conditional flask db upgrade
107+
```
77108

78109
### Database Migrations
79110

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ services:
77
- conditional-postgres
88
ports:
99
- "127.0.0.1:8080:8080"
10+
volumes:
11+
- ./migrations:/opt/conditional/migrations
1012
conditional-postgres:
1113
image: docker.io/postgres
1214
container_name: conditional-postgres

0 commit comments

Comments
 (0)