Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be74474

Browse filesBrowse files
edoardob90baffelli
andauthored
Automatically build Docker image from the repository (empa-scientific-it#80)
Co-authored-by: Simone Baffelli <simone.baffelli@gmail.com>
1 parent 285620b commit be74474
Copy full SHA for be74474

File tree

Expand file treeCollapse file tree

2 files changed

+84
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+84
-6
lines changed
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Build Tutorial Container
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '*.md'
9+
- slides/**
10+
- images/**
11+
- .gitignore
12+
workflow_dispatch:
13+
14+
jobs:
15+
repo2docker:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
packages: write
19+
steps:
20+
- name: checkout files in repo
21+
uses: actions/checkout@main
22+
23+
- name: update jupyter dependencies with repo2docker
24+
uses: jupyterhub/repo2docker-action@master
25+
with:
26+
DOCKER_USERNAME: ${{ github.actor }}
27+
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
28+
DOCKER_REGISTRY: ghcr.io
29+
IMAGE_NAME: ${{ github.repository }}

‎README.md

Copy file name to clipboardExpand all lines: README.md
+55-6Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# python-tutorial
22

3-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/empa-scientific-it/python-tutorial.git/main?labpath=index.ipynb)
4-
3+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/empa-scientific-it/python-tutorial.git/main?labpath=index.ipynb) [![Build Docker container](https://github.com/empa-scientific-it/python-tutorial/actions/workflows/build-docker-image.yml/badge.svg)](https://github.com/empa-scientific-it/python-tutorial/actions/workflows/build-docker-image.yml)
54

65
## Run the tutorial on your computer
76

8-
### 0. Prerequisites
7+
You have two ways in which you can run the tutorial **locally**.
8+
9+
### 1. With a `conda` environment
10+
11+
#### 0. Prerequisites
912

1013
To run the tutorial locally, you should first install [conda](https://docs.conda.io/en/latest/miniconda.html) (or [mamba](https://mamba.readthedocs.io/en/latest/installation.html)).
1114

1215
It is also suggested that you have a recent version of `git`. Check out [how to install `git`](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) on your operating system.
1316

14-
### 1. Download the material
17+
#### 1. Download the material
1518

1619
Go to the directory on your machine where you want to download the material and clone the repository:
1720

@@ -25,7 +28,7 @@ Alternatively, you can manually download a ZIP archive with the latest version o
2528

2629
Extract the archive in a directory of your choice.
2730

28-
### 2. Create a dedicated environment
31+
#### 2. Create a dedicated environment
2932

3033
Enter the tutorial folder with
3134

@@ -45,6 +48,7 @@ conda env create -f binder/environment.yml
4548
> If you are on Windows and using Command Prompt or the PowerShell, please make sure to adjust the paths in the commands above accordingly.
4649
4750
Then activate the environment with
51+
4852
```console
4953
conda activate python-tutorial
5054
```
@@ -55,9 +59,54 @@ You can update the existing environment (that is, downloading the latest version
5559
conda env update -f binder/environment.yml
5660
```
5761

58-
### 3. Launch the tutorial via Jupyter
62+
#### 3. Launch the tutorial via Jupyter
5963

6064
Finally, launch JupyterLab with
65+
6166
```console
6267
jupyter lab
6368
```
69+
70+
To update the existing environment, run
71+
72+
```console
73+
conda env update -f environment.yml
74+
```
75+
76+
### 2. With Docker
77+
78+
> **Note**
79+
>
80+
> The following instructions are for Windows. With minor changes, the steps work on macOS or Linux as well.
81+
82+
1. Install Docker Desktop: First, you need to install Docker Desktop on your Windows machine. You can download it from the official Docker website: https://www.docker.com/products/docker-desktop.
83+
84+
2. Create a folder: Open File Explorer and create a new folder where you want to save the tutorial's materials. For example, you could create a folder called "python-tutorial" on your Desktop.
85+
86+
3. Open PowerShell: Once Docker Desktop is installed, open PowerShell on your Windows machine. You can do this by pressing the "Windows" key and typing "PowerShell" in the search bar.
87+
88+
4. Pull the Docker image: In PowerShell, run the following command to pull the "empascientificit/python-tutorial" Docker image:
89+
90+
```console
91+
docker pull ghcr.io/empa-scientific-it/python-tutorial:latest
92+
```
93+
94+
5. Run the Docker container: Once the image is downloaded, run the following command to start a Docker container from the image:
95+
96+
```console
97+
docker run -p 8888:8888 --name python_tutorial -v /path/to/python-tutorial:/home/jovyan/work ghcr.io/empa-scientific-it/python-tutorial:latest jupyter lab --ip 0.0.0.0 --no-browser
98+
```
99+
100+
Replace `/path/to/python-tutorial` with the path to the folder you created in step 2, for example `C:/Users/yourusername/Desktop/python-tutorial`.
101+
102+
> **Note**
103+
>
104+
> The above command will **mirror** the content of your local folder (e.g., `C:/Users/yourusername/Desktop/python-tutorial`) to the `work/` folder **inside the container**. In this way, every file or folder you copy or create into `work/` will be saved on your machine, and will remain there **even if you stop Docker**.
105+
106+
6. Access the Jupyter Notebook: Open a web browser and navigate to `http://localhost:8888/lab`. You should see the Jupyter Notebook interface. Enter the token provided in the PowerShell console to access the notebook. Alternatively, you can directly click on the link that appears in the PowerShell after the container has started.
107+
108+
You can now use the Jupyter in the Docker container to run the python-tutorial. When you're done, you can stop the container by pressing `Ctrl+C` in the PowerShell console.
109+
110+
> **Note**
111+
>
112+
> If you want to restart the container, you can simply run the command `docker container start python_tutorial`.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.