-
-
Notifications
You must be signed in to change notification settings - Fork 5
Docker
Peter Chapman edited this page Sep 5, 2023
·
14 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.
- 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.
- Apple Silicon support (blocked by SIL.Machine dependency and maybe others)
- Separating the Node Frontend into a separate service (will require reworking the csproj targets).
- Node debugging support
This Docker container will run on the Vagrant machine, but will require some initial setup and configuration to do so.
After starting the vagrant machine:
cd ~/src/web-xforge/deploy/vagranta/sfdev
vagrant up
Ensure that the file "warning-not-provisioned.txt" file is no longer on the desktop, then in the virtual machine:
- 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
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 and:
- 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
- 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