Server Configuration¶
Various properties of the PrairieLearn server can be configured with a config.json file. Configuration is loaded from multiple locations and merged together, with values from later files taking precedence over earlier ones:
~/.config/prairielearn/config.json(the user's home directory - not applicable when running in Docker)./config.json(the repository root directory)./apps/*/config.json(the application root directories)
For example, if ./config.json sets "courseDirs" and ./apps/prairielearn/config.json sets "isEnterprise", the final configuration will include both values. If both files set the same property, the value from ./apps/prairielearn/config.json will be used.
The file is structured as a JSON dictionary with the following syntax:
{
"property1": "...",
"property2": "...",
"property3": "..."
}
A full list of properties can be found in lib/config.ts.
Setting Course Directories¶
The default course directories to be loaded by PrairieLearn can be overridden with the "courseDirs" setting. This setting takes a list of paths to load that are located in the Docker container.
{
"courseDirs": ["exampleCourse", "testCourse", "/myCourse"]
}
Note
These directories are paths in the container, not on your local computer.
To mount a directory on your computer so that it is accessible in the container, you can add the following to your Docker run command:
-v /path/to/myCourse:/myCourse
Then, the path will be accessible at /myCourse (note the beginning slash).
Setting up external image capture locally¶
The pl-image-capture element lets users capture images of submitted work through an external device, such as a mobile device or tablet, or a local camera.
To use external capture locally, you must set serverCanonicalHost in config.json to your local IPv4 address.
To retrieve your local IPv4 address, if you're on
- macOS: in Terminal, run
ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
- Linux: in your terminal, run
ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'
- Windows: in Command Prompt, run
ipconfig | findstr /C:"IPv4"
Copy the first address you see, and paste it into the serverCanonicalHost property of your config.json file.
For example, if your IPv4 is 192.168.1.60 and PL is running on port 3000, your file should read:
{
"serverCanonicalHost": "http://192.168.1.60:3000"
}
Workspaces and external graders¶
You should set the workspace host home directory root and home directory root in your config.json.
{
"workspaceHostHomeDirRoot": "/tmp/workspace",
"workspaceHomeDirRoot": "/tmp/workspace"
}
Running workspaces / external graders natively on macOS¶
If you are running workspaces natively on macOS, you may need to change "workspaceDevContainerHostname" to "localhost".
{
"workspaceDevContainerHostname": "localhost"
}
Certain images detect if you are running as root and try to chown the workspace files to the user 1001 before stepping down to the user 1001 (pl-gosu-helper.sh). On macOS, this will fail because bind mounts cannot be chown'd (FUSE-based filesystems). To fix this, you can set "workspaceJobsDirectoryOwnerUid" and "workspaceJobsDirectoryOwnerGid" to 1001 in your config.json.
{
"workspaceJobsDirectoryOwnerUid": 1001,
"workspaceJobsDirectoryOwnerGid": 1001
}
Many containers can only run as UID 1001 or 0. Make sure you run as root locally!
sudo make dev-workspace-host
sudo make dev
If you don't both of these commands, you will see errors like:
chown: changing ownership of '/home/coder/workspace': Permission denied
chown: changing ownership of '/home/coder/workspace/fibonacci.py': Permission denied
Testing local docker images¶
When testing docker images locally, you may want to force PrairieLearn to use the local version of an image.
{
"workspacePullImagesFromDockerHub": false,
"externalGradingPullImagesFromDockerHub": false
}
Enterprise¶
Some features of PrairieLearn are only available in the Enterprise Edition. Note that you must adhere to the PrairieLearn license when setting this option.
{
"isEnterprise": true
}