-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created dockerfile to run on container
- Loading branch information
1 parent
d118f03
commit b9031bc
Showing
3 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#Download base image ubuntu 18.04 | ||
FROM ubuntu:22.04 | ||
|
||
# Set root user | ||
USER root | ||
|
||
# Update Ubuntu Software repository and install python, jupyter lab and git | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
curl \ | ||
python3 \ | ||
python3-pip \ | ||
git \ | ||
&& \ | ||
python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install \ | ||
jupyterlab \ | ||
IM-client | ||
|
||
# Optional: Clean up package cache to reduce image size | ||
RUN apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create the script to init jupyter lab | ||
RUN echo "#!/bin/bash" > /bin/jupyter-apricot && \ | ||
echo "jupyter lab --ip 0.0.0.0 --no-browser" >> /bin/jupyter-apricot && \ | ||
chmod +x /bin/jupyter-apricot | ||
|
||
# Create a user for jupyter lab | ||
RUN useradd -ms /bin/bash jupyteruser | ||
|
||
# Change to jupyter lab user | ||
USER jupyteruser | ||
WORKDIR /home/jupyteruser | ||
|
||
# Clone git, install, get the examples and clear files | ||
#RUN git clone https://github.com/grycap/apricotlab.git && cd /home/jupyteruser/apricot | ||
#\ | ||
# && sh install.sh && cd /home/jupyteruser && cp -r apricot/examples . && mv apricot .apricot_git | ||
|
||
# Set entry point | ||
ENTRYPOINT ["/bin/jupyter-apricot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Welcome to the APRICOT extension. This plugin designed for Jupyter Notebooks allows you to deploy and manage virtual infrastructures using the Infrastructure Manager. In this notebook, we will cover the basics to help you get started with APRICOT.\n", | ||
"\n", | ||
"First of all, let's create create a simple infrastructure to execute the following example notebook. To do so, click in the **Infrastructure deployment** button in the toolbar above and follow the steps to deploy your first infrastructure. Any infrastructure should be able to execute all commands.\n", | ||
"\n", | ||
"Once the infrastructure has been deployed, we can start playing with the notebook." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Before using any magic command, we have to load apricot magics:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%reload_ext apricot_magics" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can check the status of all the infrastructures we have already deployed, along with their IDs and more information about them:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot_ls" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"To begin with the tutorial, please paste the infrastructure ID inside the **infrastructure_id** variable:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"infrastructure_id = \"309267ba-2703-11ef-ab62-6a189102e506\"\n", | ||
"vm_id = \"0\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Using the ID of our new infrastructure, we can get more information about it:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot_vmls $infrastructure_id" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can execute different Linux commands on the virtual machines using the infrastructure ID and the ID of one of its nodes. Let's practice it by creating a file named \"test123.txt\" on the first node:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot exec $infrastructure_id $vm_id touch \"test123.txt\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can check the new file in the VM:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot exec $infrastructure_id $vm_id ls" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let's download the file to our local storage:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot_download $infrastructure_id $vm_id test123.txt ." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%bash\n", | ||
"ls" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Once we have finished playing with our infrastructure, we can destroy it:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%apricot destroy $infrastructure_id" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Congratulations! You finished the tutorial and now you are free to keep exploring and exploiting the APRICOT extension!" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters