You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-21Lines changed: 28 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,20 +11,28 @@ If you're unfamiliar with CSM and/or its web applications, check out [this repos
11
11
We don't know what specific minimum version you would need for any of the following software, but the most recent version of any of the below should work.
12
12
13
13
- Python 3.9.13
14
-
- It is recommended that you use [`pyenv`](https://github.com/pyenv/pyenv)to manage python versions, so that you can use a consistent python version for `csm_web`, and another python version for your other projects.
14
+
- It is recommended that you use a python version manager like [`pyenv`](https://github.com/pyenv/pyenv)or [`asdf`](https://asdf-vm.com) (with [`asdf-python`](https://github.com/asdf-community/asdf-python)), so that you can use a consistent python version for `csm_web`, and another python version for your other projects.
- We use poetry to manage python dependencies; this should be installed _outside_ of a virtual environment.
17
+
- Although everything will be run through Docker containers, you should use Poetry to get the dependencies locally for editing.
16
18
-`npm`
17
-
- It is recommended that you use [`nvm`](https://github.com/nvm-sh/nvm) to manage node/npm versions, so that you can use a consistent node/npm version for `csm_web`, and another verison for your other projects.
- It is recommended that you use a node version manager like [`nvm`](https://github.com/nvm-sh/nvm), [`n`](https://github.com/tj/n), or [`asdf`](https://asdf-vm.com) (with [`asdf-nodejs`](https://github.com/asdf-vm/asdf-nodejs)), so that you can use a consistent node/npm version for `csm_web`, and another verison for your other projects.
20
+
- Although everything will be run through Docker containers, you should get the dependencies locally for editing.
21
+
-[Docker](https://www.docker.com)
22
+
- Your development environment will be hosted through docker containers, so that you do not need to do much local setup.
- We use an S3 bucket to store course resources. See [here](https://aws.amazon.com/s3/) to get started.
23
-
- Log in to AWS CLI (`aws configure`) This will prompt an interactive session to enter login credentials.
24
-
- AWS Access Key ID: (ask tech chair)
25
-
- AWS Secret Access Key: (ask tech chair)
26
-
- Default region name: `us-east-1`
27
-
- Default output format: `json`
30
+
- Log in to AWS CLI (`aws configure`) This will prompt an interactive session to enter login credentials.
31
+
- AWS Access Key ID: (ask tech chair)
32
+
- AWS Secret Access Key: (ask tech chair)
33
+
- Default region name: `us-east-1`
34
+
- Default output format: `json`
35
+
- This is not completely necessary for the application to work locally; it is only used for interactions with the resources page in production/staging.
28
36
29
37
Other miscellaneous requirements will be installed by the commands below.
30
38
@@ -34,23 +42,23 @@ To ensure package version consistency and avoid polluting your global package in
34
42
35
43
Firstly, make sure you have the right python version (see `runtime.txt` for the expected python version to install). If you're using `pyenv` to manage python versions (this is recommended), you can install the specified python version with `pyenv install <version>`.
36
44
37
-
From a terminal in the top level of the project directory, run `python3 -m venv venv`; if your system python version is different from the version required here, and you're using `pyenv`, run `PYENV_VERSION=<version> python3 -m venv venv` instead (for example, `PYENV_VERSION=3.9.13 python3 -m venv venv`). This will initialize a new virtual environment in the `venv/` folder, with the correct base python version.
45
+
Next, make sure that your current python version is correct (i.e. as specified in the previous section); if it is different, then change to the correct python version. That is, with `pyenv`, run `pyenv local <version>`; with `asdf`, run `asdf local python <version>`.
38
46
39
-
To activate the environment, run `source venv/bin/activate`. You will need to run this command every time you open a new terminal.
47
+
Finally, run `./setup.sh`. This will install additional requirements needed by the server, and set up some necessary environment variables. In particular, the setup script installs all dependencies locally and builds the Docker images.
40
48
41
-
Finally, run `./setup.sh`. This will install additional requirements needed by the server, and set up some necessary environment variables. You should _not_ be running this script after it has succeeded and set up the environment for the first time.
49
+
Note that generally, you should not need to run `setup.sh`after first setting up the repository.
42
50
43
51
## Running
44
52
45
-
To start the Django server, run `python3 csm_web/manage.py runserver`and visit `localhost:8000`in your browser.
53
+
To start the Django server and other services, make sure Docker is up and run `docker compose up -d`. This will start Django, automatically compile and watch frontend files, and start a development database. (The `-d` puts the process in the background.)
46
54
47
-
Run `python3 csm_web/manage.py createtestdata` to generate some test data. If you ran `./setup.sh`,
48
-
this was done for you.
55
+
To generate test data, run `docker compose exec django python3 csm_web/manage.py createtestdata`. In general, if you'd like to run any commands in the Django docker container, run `docker compose exec django <command>`. (You can make an alias in your shell if you'd like to avoid typing all of this each time.)
49
56
50
-
_If you are working on the frontend_:
57
+
If all of the above has worked, visit [http://localhost:8000](http://localhost:8000) in your browser and you should see a log in screen; don't actually use this to actually log in locally. Visit [http://localhost:8000/admin/](http://localhost:8000/admin/) to log in instead.
51
58
52
-
Run `npm run watch`, which will automatically rebuild the JS bundle if any changes to the frontend JS are detected.
53
-
Alternatively you can run `npm run dev` manually each time you make changes to the frontend.
59
+
Any changes will automatically reload the server in the docker containers, but you will usually need to force refresh (`ctrl + shift + R` or `cmd + shift + R` on most browsers) for frontend changes to be reflected (this clears the browser cache for the page).
60
+
61
+
During development, you should use the virtual environment as much as possible---while Docker makes this less necessary, your choice of editor may require the dependencies in the virtual environment. To activate the virtual environment, you can use `poetry shell` (this will start a new nested shell instance), or you can use `source .venv/bin/activate` (more generally, `source $(poetry env info --path)/bin/activate`).
54
62
55
63
## Troubleshooting
56
64
@@ -122,5 +130,4 @@ could not connect to server: Connection refused
122
130
TCP/IP connections on port 5432?
123
131
```
124
132
125
-
Your postgres server is likely not running. On a mac (which is the only platform we've done local
126
-
testing on), run `brew services start postgres` before invoking `runserver` again.
133
+
Your PostgreSQL server is likely not running. On MacOS, run `brew services start postgres` before invoking `runserver` again; on Unix, run `sudo service postgresql restart` before invoking `runserver` again.
0 commit comments