Skip to content

Commit 449aa08

Browse files
authored
Merge pull request #17 from SciCatProject/production-prep
Add docker automation and CI workflow needed for production deployments
2 parents 4bfe400 + 24c44b1 commit 449aa08

File tree

5 files changed

+127
-2
lines changed

5 files changed

+127
-2
lines changed

.github/workflows/docker_release.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Docker Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Bump version and push tag
16+
id: tag_version
17+
uses: mathieudutour/[email protected]
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
release_branches: release
21+
22+
- name: Create a GitHub release
23+
uses: ncipollo/release-action@v1
24+
with:
25+
tag: ${{ steps.tag_version.outputs.new_tag }}
26+
name: Release ${{ steps.tag_version.outputs.new_tag }}
27+
body: ${{ steps.tag_version.outputs.changelog }}
28+
29+
- name: Create Docker Metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/scicatproject/sciwyrm
34+
flavor: latest=true # adds :latest tag to outputs.tags
35+
tags: | # adds :<sha> tag to outputs.tags
36+
type=sha,format=long,prefix=
37+
type=raw,value=${{ steps.tag_version.outputs.new_tag }}
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Login to GitHub Container Registry
43+
uses: docker/login-action@v3
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Build Docker Image
50+
uses: docker/build-push-action@v4
51+
with:
52+
platforms: linux/amd64,linux/arm64
53+
context: ./
54+
file: ./docker/Dockerfile
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ cython_debug/
160160
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161161
# and can be added to the global gitignore or merged into this file. For a more nuclear
162162
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
163-
#.idea/
163+
.idea/
164+
#
165+
#
166+
# local files
167+
local/

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,53 @@ access:
2121
navigate browser to:
2222
http://localhost:8000/docs
2323
```
24+
25+
In order to test, you can submit the following POST request , once you have the service running locally:
26+
```
27+
curl \
28+
-H 'Content-Type: application/json' \
29+
-d '{
30+
"template_id" : "b32f6992-0355-4759-b780-ececd4957c23",
31+
"parameters" : {
32+
"dataset_pids" : [ "dataset_pid_1" ,"dataset_pid_2" ],
33+
"file_server_host" : "this_file_server",
34+
"file_server_port" : 22,
35+
"scicat_url" : "my.scicat.instance",
36+
"scicat_token" : "my.scicat.token"
37+
}
38+
}' \
39+
-X POST \
40+
http://localhost:8000/notebook
41+
```
42+
as a one liner, ready to be run, it looks like:
43+
```
44+
curl -H 'Content-Type: application/json' -d '{ "template_id" : "b32f6992-0355-4759-b780-ececd4957c23", "parameters" : {"dataset_pids":["dataset_pid_1","dataset_pid_2"],"file_server_host": "this_file_server","file_server_port" : 22, "scicat_url":"my.scicat.instance", "scicat_token" : "my.scicat.token"}}' -X POST http://localhost:8000/notebook
45+
```
46+
47+
This request should result in an populated instance of the template b32f6992-0355-4759-b780-ececd4957c23.ipynb included in the repository.
48+
49+
## Docker Image
50+
A docker image is created by a dedicated workflow every time there is a new release by merging a PR in the `release` branch.
51+
52+
In case a users or developer has the need to create locally a docker image and deploy the container, the following commands can be used, assuming that image name `sciwyrm` and the container name is `scijug`:
53+
54+
Docker image creation
55+
```
56+
docker build -f docker/Dockerfile . -t sciwyrm
57+
58+
```
59+
60+
Docker container instantiation
61+
```
62+
docker create --name scijug -p 8000:8000 sciwyrm
63+
```
64+
65+
The Jupyter creation service will be available on http://localhost:8000
66+
67+
## Contribution
68+
All contributors should create a branch dedicated branch to develop their feature and [performing their work.
69+
Once the code is in a ready, the contribution should be done through a PR to the main branch, where maintainers can review, provide feedback and approve it.
70+
71+
## Releases
72+
Release are managed by maintainers by creating PRs from the main branch to the release branch.
73+
Merging a PR in release trigger a git workflow that creates a release in the repository and also the creation of a docker image with the version of the service released.

docker/Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Use the official Python image from the Docker Hub
2+
FROM python:3.12
3+
4+
# Set the working directory in the container
5+
WORKDIR /code
6+
7+
# Copy the requirements file into the container
8+
COPY . .
9+
10+
# Install the dependencies
11+
RUN pip install "uvicorn[standard]"
12+
RUN pip install -e .
13+
14+
# command to run
15+
CMD ["uvicorn", "sciwyrm.main:app", "--host", "0.0.0.0"]

templates/notebook/b32f6992-0355-4759-b780-ececd4957c23.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"name": "python",
155155
"nbconvert_exporter": "python",
156156
"pygments_lexer": "ipython3",
157-
"version": "3.11.5"
157+
"version": "3.12.9"
158158
}
159159
},
160160
"nbformat": 4,

0 commit comments

Comments
 (0)