Skip to content

Commit b8a5e9d

Browse files
authored
Merge pull request #2 from pythonhealthdatascience/docker
Docker
2 parents 2ea6799 + 4fd369c commit b8a5e9d

File tree

5 files changed

+151
-3
lines changed

5 files changed

+151
-3
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish docker on GHCR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
force_docker_build:
9+
description: 'Force Docker build (skip change detection)'
10+
required: true
11+
type: boolean
12+
default: false
13+
skip_docker_build:
14+
description: 'Skip Docker build (use last built image)'
15+
required: true
16+
type: boolean
17+
default: false
18+
19+
jobs:
20+
publish-docker:
21+
name: Publish docker
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Check if Docker build needed
32+
id: changes
33+
uses: dorny/paths-filter@v3
34+
with:
35+
filters: |
36+
docker:
37+
- 'binder/Dockerfile'
38+
- 'binder/environment.yml'
39+
40+
- name: Login to GitHub Container Registry
41+
if: >
42+
(!inputs.skip_docker_build) &&
43+
(inputs.force_docker_build || steps.changes.outputs.docker == 'true')
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Build the Docker image
51+
if: >
52+
(!inputs.skip_docker_build) &&
53+
(inputs.force_docker_build || steps.changes.outputs.docker == 'true')
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
file: binder/Dockerfile
58+
tags: |
59+
ghcr.io/pythonhealthdatascience/llm_simpy_models:latest
60+
push: true
61+

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Dates formatted as YYYY-MM-DD as per [ISO standard](https://www.iso.org/iso-8601-date-and-time-format.html).
77

8+
## v1.0.3 - 2025-12-02
9+
10+
Add docker image and hosted on GitHub Container Registry.
11+
12+
### Added
13+
14+
* Add `Dockerfile` which builds conda environment and runs the app.
15+
* Add GitHub action which builds Docker image and pushes to GitHub Container Registry.
16+
17+
### Changed
18+
19+
* Explained how to use Docker (and venv) in README.
20+
821
## v1.0.2 - 2025-03-25
922

1023
Add note about `st.spinner()` to the home page.

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ repository-code: 'https://github.com/pythonhealthdatascience/llm_simpy_models'
2929
abstract: >-
3030
The SimPy models and apps generated by LLMs, deployed as a single app.
3131
license: MIT
32-
version: '1.0.2'
33-
date-released: '2025-03-25'
32+
version: '1.0.3'
33+
date-released: '2025-12-02'

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ For a full record of the generation of these models, please refer to: https://gi
3939

4040
## 🌐 Creating the environment
4141

42+
### conda
43+
4244
The project uses `conda` to manage dependencies. Navigate your terminal to the directory containing the code and run:
4345

4446
```
@@ -51,7 +53,53 @@ This will create a conda environment called `gen_simpy_apps`. To activate:
5153
conda activate gen_simpy_apps
5254
```
5355

54-
This environment is a simplified version of that from the [llm_simpy](https://github.com/pythonhealthdatascience/llm_simpy) repository, containing only the dependencies required for running the apps.
56+
This environment is a simplified version of that from the [llm_simpy](https://github.com/pythonhealthdatascience/llm_simpy) repository, containing only the dependencies required for running the models and apps.
57+
58+
### venv
59+
60+
Another option is to use `venv`. You can build the environment by running:
61+
62+
```
63+
python -m venv venv
64+
```
65+
66+
Then install the packages using:
67+
68+
```
69+
pip install -r requirements.txt
70+
```
71+
72+
`venv` cannot control which python version is used, it will just use one on system. You can check what this is by running:
73+
74+
```
75+
venv/bin/python --version
76+
```
77+
78+
You can find the version of python used for the models and app in the `binder/environment.yaml` file.
79+
80+
### Docker
81+
82+
Alternatively, a docker environment has been provided.
83+
84+
You can build the image by running:
85+
86+
```
87+
docker build -f binder/Dockerfile -t gen_simpy_apps .
88+
```
89+
90+
Another option is to pull the image from the GitHub Container Registry:
91+
92+
```
93+
docker pull ghcr.io/pythonhealthdatascience/llm_simpy_models:latest
94+
```
95+
96+
Once you have the build image, you can then run the container:
97+
98+
```
99+
docker run -p 8501:8501 gen_simpy_apps
100+
```
101+
102+
Open your browser to <http://localhost:8501/> to view the app.
55103

56104
<br>
57105

binder/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM mambaorg/micromamba:latest
2+
3+
# Needed for micromamba activation in Dockerfile RUN commands
4+
ARG MAMBA_DOCKERFILE_ACTIVATE=1
5+
6+
# Workdir inside container
7+
WORKDIR /app
8+
9+
# Copy only env first to leverage layer caching
10+
COPY binder/environment.yml /tmp/environment.yml
11+
12+
# Create the conda env
13+
RUN micromamba env create -f /tmp/environment.yml && \
14+
micromamba clean --all --yes
15+
16+
# Now copy the rest of the project
17+
COPY . /app
18+
19+
# Default environment name; adjust if changes in environment.yml
20+
ENV CONDA_DEFAULT_ENV=gen_simpy_apps
21+
ENV PATH=/opt/conda/envs/gen_simpy_apps/bin:$PATH
22+
23+
EXPOSE 8501
24+
25+
# Use shell-form so the env is active via MAMBA_DOCKERFILE_ACTIVATE
26+
CMD ["streamlit", "run", "Home.py", "--server.address=0.0.0.0", "--server.port=8501"]

0 commit comments

Comments
 (0)