- Docker Engine 19.03.0+
- Docker Compose
- Bash interpreter
Clone this repository.
git clone https://github.com/ComputeCanada/mc-hub.git
Then, run the development Docker container. This documentation shows two ways of achieving this: with a regular setup or with VS Code.
Note: When running this development container, three important bind mounts will be created:
- A bind mount between the project's
app
directory and the container's/home/mcu/app
directory to ensure that modifications in the backend code are applied instantly. However, the container cannot modify this directory, it is readonly.- A bind mount between the project root directory and the container's
/workspace
directory. This bind mount is necessary to modify the application code in the running container from the host system.- A bind mount between the project's
clusters_backup
directory and the container's/home/mcu/clusters
directory to ensure that Terraform state files and logs are backed up.
- Start the Docker container.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build docker-compose up
- Open your browser and navigate to
http://localhost:5000
.
-
Install the Remote - Containers VS Code extension.
-
Start VS Code and run
Remote-Containers: Open Folder in Container
command from the Command Pallette (F1
). Then, select the repository folder. -
Open your browser and navigate to
http://localhost:5000
. -
Install the Python extension in the Dev Container.
You can modify any file in the /workspace/app
directory without a rebuild, because of the bind mount created previously.
By default, modifications to the frontend code (in /workspace/frontend
) do require a rebuild.
However, you can easily run a node development server inside the development container. First, you will need to explicitly specify the VUE_APP_API_URL
environment variable, because the development server runs on a different port (8080) from the Flask server. Here is an example with the Flask server running on port 5000.
cd /workspace/frontend
echo "VUE_APP_API_URL=http://localhost:5000/api" > .env.development.local
Then, you can start the Node development server.
npm run serve
This will spawn a node server (most likely on http://localhost:8080
) which will automatically reload the frontend code on any modification.
To make the npm development server run faster, install and run npm on the host machine.
If there was a problem when modifying a cluster using the UI or you want to access the terraform logs, this section if for you.
- Start a shell within your running container.
- Go to the directory of the target cluster.
cd ~/clusters/<CLUSTER NAME>.<DOMAIN>
- Then, you can run any terraform command.
Open the terminal on your host machine and access the clusters_backup
directory.
- Navigate to
<PROJECT DIR>/clusters_backup/<CLUSTER_NAME>.<DOMAIN>
. - Delete the folder named
.terraform
. - Download magic_castle-openstack-7.3.zip
- Extract the folder and copy the
openstack
folder in<PROJECT DIR>/clusters_backup/<CLUSTER_NAME>.<DOMAIN>
. - Edit the following line in main.tf:
And change it for:
source = "/home/mcu/magic_castle-openstack-7.3/openstack"
source = "./openstack"
- Open a terminal and run the following command:
terraform init
- Now, you should be able to modify the cluster on your host machine with terraform.
terraform show