Skip to content

Commit e526421

Browse files
authored
Initial commit
0 parents  commit e526421

File tree

5 files changed

+237
-0
lines changed

5 files changed

+237
-0
lines changed

Diff for: .github/workflows/docker-publish.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
schedule:
10+
- cron: '23 21 * * *'
11+
push:
12+
branches: [ "main" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "main" ]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
25+
jobs:
26+
build:
27+
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
packages: write
32+
# This is used to complete the identity challenge
33+
# with sigstore/fulcio when running outside of PRs.
34+
id-token: write
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
# Install the cosign tool except on PR
41+
# https://github.com/sigstore/cosign-installer
42+
- name: Install cosign
43+
if: github.event_name != 'pull_request'
44+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
45+
with:
46+
cosign-release: 'v2.2.4'
47+
48+
# Set up BuildKit Docker container builder to be able to build
49+
# multi-platform images and export cache
50+
# https://github.com/docker/setup-buildx-action
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
53+
54+
# Login against a Docker registry except on PR
55+
# https://github.com/docker/login-action
56+
- name: Log into registry ${{ env.REGISTRY }}
57+
if: github.event_name != 'pull_request'
58+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
59+
with:
60+
registry: ${{ env.REGISTRY }}
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
# Extract metadata (tags, labels) for Docker
65+
# https://github.com/docker/metadata-action
66+
- name: Extract Docker metadata
67+
id: meta
68+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
69+
with:
70+
images: ghcr.io/socstech/MODULE # THIS LINE MUST BE EDITED FOR NEW MODULES
71+
72+
73+
# Build and push Docker image with Buildx (don't push on PR)
74+
# https://github.com/docker/build-push-action
75+
- name: Build and push Docker image
76+
id: build-and-push
77+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
78+
with:
79+
context: .
80+
file: ./MODULE FOLDER/.devcontainer/Dockerfile # THIS LINE MUST BE EDITED FOR NEW MODULES
81+
push: ${{ github.event_name != 'pull_request' }}
82+
# THIS LINE MUST BE EDITED FOR NEW MODULES
83+
tags: |
84+
${{ steps.meta.outputs.tags }}
85+
ghcr.io/socstech/MODULE:latest
86+
labels: ${{ steps.meta.outputs.labels }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
90+
# Sign the resulting Docker image digest except on PRs.
91+
# This will only write to the public Rekor transparency log when the Docker
92+
# repository is public to avoid leaking data. If you would like to publish
93+
# transparency data even for private images, pass --force to cosign below.
94+
# https://github.com/sigstore/cosign
95+
- name: Sign the published Docker image
96+
if: ${{ github.event_name != 'pull_request' }}
97+
env:
98+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
99+
TAGS: ${{ steps.meta.outputs.tags }}
100+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
101+
# This step uses the identity token to provision an ephemeral certificate
102+
# against the sigstore community Fulcio instance.
103+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

Diff for: MODULE/.devcontainer/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM python:3.12
2+
RUN pip install --upgrade pip
3+
RUN pip install ipykernel
4+
CMD ["clear"]

Diff for: MODULE/.devcontainer/devcontainer.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "MODULE",
3+
4+
"image": "ghcr.io/socstech/MODULE:latest",
5+
6+
//"build": { "dockerfile": "Dockerfile" },
7+
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-azuretools.vscode-docker",
12+
"ms-toolsai.jupyter",
13+
"ms-toolsai.vscode-jupyter-cell-tags",
14+
"ms-toolsai.jupyter-renderers",
15+
"ms-toolsai.vscode-jupyter-slideshow",
16+
"ms-python.vscode-pylance",
17+
"ms-python.python",
18+
"ms-python.debugpy",
19+
"ms-toolsai.jupyter-keymap"
20+
]
21+
}
22+
}
23+
}

Diff for: MODULE/test.ipynb

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import seaborn"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 2,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import pandas"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 3,
24+
"metadata": {},
25+
"outputs": [],
26+
"source": [
27+
"import scipy"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": 4,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"import sklearn"
37+
]
38+
}
39+
],
40+
"metadata": {
41+
"kernelspec": {
42+
"display_name": "Python 3",
43+
"language": "python",
44+
"name": "python3"
45+
},
46+
"language_info": {
47+
"codemirror_mode": {
48+
"name": "ipython",
49+
"version": 3
50+
},
51+
"file_extension": ".py",
52+
"mimetype": "text/x-python",
53+
"name": "python",
54+
"nbconvert_exporter": "python",
55+
"pygments_lexer": "ipython3",
56+
"version": "3.12.4"
57+
}
58+
},
59+
"nbformat": 4,
60+
"nbformat_minor": 2
61+
}

Diff for: README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# MODULE TITLE
2+
This repository houses the devcontainer and docker image for the MODULE module at the University of Lincoln.
3+
## What is Docker?
4+
Docker is a platform which allows developers to create and share containers.
5+
6+
A container is an environment separate from your main operating system, which includes all of the requirements to run a piece of software. You can think of it like a box which you can take anywhere,
7+
and when opened, the software inside works exactly the same way, no matter where you are running it.
8+
9+
This helps us technicians to give every module the exact coding environment it needs, without causing any conflicts.
10+
11+
If you would like to learn more about how Docker works in your labs, please feel free to contact us at [email protected].
12+
13+
## How do I use the Docker container for this module at home?
14+
15+
We strongly recommend using the Docker container for your modules on your personal devices, as it recreates the exact coding environment you use in the labs without installing lots of stuff on your computer which may conflict with the required software for other modules you are studying.
16+
17+
### Prerequisites
18+
19+
These prerequisites are the same for every Computer Science module using Docker containers, so you should only need to do this once and it will work for the rest of your degree.
20+
21+
1. Download and install Docker Desktop: https://www.docker.com/products/docker-desktop/
22+
23+
2. Download and install VSCode: https://code.visualstudio.com/
24+
25+
3. Install the Remote Development extension for VSCode: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
26+
27+
### Process
28+
29+
1. Clone this repository to your computer by clicking the green 'Code' button, and clicking 'Download ZIP'.
30+
2. Extract the downloaded Zip file.
31+
3. Inside the extracted folder is a folder entitled 'MODULE FOLDER' which contains the .devcontainer folder. Move 'MODULE FOLDER' to wherever you like, this will be your working directory for this module.
32+
4. Make sure Docker Desktop is running. You can minimise the window.
33+
5. Open VS Code, go to File -> Open Folder, and select your 'MODULE FOLDER' folder.
34+
6. Click the 'Reopen in container' pop up in the bottom right corner of your VS Code window. If you do not see this pop up, press F1, and type 'Reopen in Container', and click on the 'Dev Containers: Reopen in Container' command.
35+
7. The Docker image will now be downloaded, and the container will be started. You can click 'show log' in the bottom right corner to see what is going on.
36+
8. Your docker container is now running! Within this VS Code window, you can now run workshop or assignment material exactly the same as in the computing labs.
37+
9. If we ever push an update to the container, you will need to go to Docker Desktop -> Images, find ghcr.io/socstech/MODULE, click the ... button, and click pull. This will pull the most recent version of the docker container. There should be Blackboard announcements letting you know if you ever need to do this, but it is good to do this step every time before you want to use the container.
38+
39+
### Troubleshooting
40+
41+
If you are struggling to get this to work, try these common troubleshooting steps:
42+
43+
1. Restart your computer. Always a good start.
44+
2. Make sure Docker Desktop is open and running.
45+
3. Make sure Docker Desktop is updated.
46+
4. Make sure VS Code has the Remote Development extension pack. You can install this through the Extensions tab in VS Code if it isn't working through the web link above.

0 commit comments

Comments
 (0)