-
-
Notifications
You must be signed in to change notification settings - Fork 5
Docker
Peter Chapman edited this page Oct 9, 2024
·
10 revisions
Scripture Forge has a Docker container, which can be used for running in a development environment.
- Ensure that Docker is installed. The easiest way is with Docker Desktop.
- Add developer secrets. Ask another developer how to get these.
- If the MongoDB service is running on your computer, stop it:
-
Linux:
sudo systemctl stop mongod
-
Windows:
sc stop mongodb
-
Linux:
- Change to the
src/Docker
directory - Build the container:
docker compose build
- Start the container:
docker compose up
- Shutdown the container by pressing Ctrl+C
- Run the task: docker-compose-up
- To debug .NET, use the "Docker .NET Attach (Preview)" configuration
- Change the project dropdown in the Visual Studio toolbar to: "Docker"
- Run: "Docker Compose"
- By default your user secrets will be imported into the container.
- If you encounter issues with this, you may need to copy them from
~/.microsoft/usersecrets/4d0606c3-0fc7-4d76-b43b-236485004e81/secrets.json
to/root/.microsoft/usersecrets/4d0606c3-0fc7-4d76-b43b-236485004e81/secrets.json
- If you encounter issues with this, you may need to copy them from
- Currently only debugging .NET code is supported.
- The .override.yml file contains configuration that is loaded by default on developer machines to help the container run in a dev friendly way.
- This configuration has been tested on Windows 11 and Ubuntu 23.04 using the latest Docker Desktop, and Ubuntu 20.04 using Docker Engine.
- Your Scripture Forge directory should be in a functional state before building the image. Follow the Cleaning instructions if the image is not building.
- If that fails, reset your Docker state:
- Stop all docker containers.
- Run
docker system prune -a
to delete all images.
This Docker container will run on the Vagrant machine, but will require some initial setup and configuration to do so.
Note: This is not something you will need to do, unless you use the Vagrant machine for development.
Start the vagrant guest machine by running the following on your host:
cd web-xforge/deploy/vagrant/sfdev
vagrant up
In the guest, ensure that the file "warning-not-provisioned.txt" file is no longer on the desktop.
In the vagrant guest, do the following.
- Click "Install Now" to the Software Updater dialog.
- When the Updater has finished, click "Restart Now".
- Open a terminal and run (substituting values where enclosed in
{}
brackets):
# Update packages
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
# Setup Git
git config --global user.name "{my_name}"
git config --global user.email "{my_email}"
# Add Docker GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker repo
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add vagrant user to docker group
sudo groupadd -f docker
sudo usermod -aG docker $USER
newgrp docker
# Test Docker
docker run hello-world
# Configure user secrets
cd ~/src/web-xforge/src/SIL.XForge.Scripture
dotnet user-secrets set "Auth:BackendClientSecret" "{backend_client_secret}"
dotnet user-secrets set "Paratext:ClientId" "{paratext_client_id}"
dotnet user-secrets set "Paratext:ClientSecret" "{paratext_client_secret}"
dotnet user-secrets set "Paratext:ResourcePasswordHash" "{paratext_resource_password_hash}"
dotnet user-secrets set "Paratext:ResourcePasswordBase64" "{paratext_resource_password_base64}"
# Create debugger directory (before it's created later with root ownership)
mkdir ~/.vsdbg
- Reboot the vagrant machine (to apply the new docker group)
- Open a terminal and run:
# Stop Mongo
sudo systemctl stop mongod
# Build the Docker image
cd ~/src/web-xforge/src/Docker
docker compose build
docker compose up
- Open http://localhost:5000/ using a web browser, and log into Scripture Forge.
- Run Visual Studio Code.
- In Visual Studio Code, do the following.
- Open the folder "~/src/web-xforge"
- Click "Yes, I trust the authors"
- Click the Extensions button in the sidebar
- In the Recommended list, click "Install" next to Docker
- Wait. Next to the C# extension, click "Reload Required"
- Click the Run and Debug button in the sidebar
- Click the down arrow in the configuration selector and select "Docker .NET Attach (Preview)"
- Click the Play button
- Select the process "dotnet" from the dropdown that will appear at the top center of the window