From 3f57d1895b6625014bfe79ac817ba7e3f1b0724b Mon Sep 17 00:00:00 2001 From: amyheather Date: Tue, 2 Dec 2025 11:17:06 +0000 Subject: [PATCH 1/5] build(docker): add dockerfile (tested, works fine) --- binder/Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 binder/Dockerfile diff --git a/binder/Dockerfile b/binder/Dockerfile new file mode 100644 index 0000000..1f4f878 --- /dev/null +++ b/binder/Dockerfile @@ -0,0 +1,26 @@ +FROM mambaorg/micromamba:latest + +# Needed for micromamba activation in Dockerfile RUN commands +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# Workdir inside container +WORKDIR /app + +# Copy only env first to leverage layer caching +COPY binder/environment.yml /tmp/environment.yml + +# Create the conda env +RUN micromamba env create -f /tmp/environment.yml && \ + micromamba clean --all --yes + +# Now copy the rest of the project +COPY . /app + +# Default environment name; adjust if changes in environment.yml +ENV CONDA_DEFAULT_ENV=gen_simpy_apps +ENV PATH=/opt/conda/envs/gen_simpy_apps/bin:$PATH + +EXPOSE 8501 + +# Use shell-form so the env is active via MAMBA_DOCKERFILE_ACTIVATE +CMD ["streamlit", "run", "Home.py", "--server.address=0.0.0.0", "--server.port=8501"] From 0674053daa91ce675bf1841f9bc79ff765b7ab07 Mon Sep 17 00:00:00 2001 From: amyheather Date: Tue, 2 Dec 2025 11:17:19 +0000 Subject: [PATCH 2/5] ci(docker): add action to publish docker on GHCR --- .github/workflows/publish-docker.yaml | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/publish-docker.yaml diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml new file mode 100644 index 0000000..55cca2b --- /dev/null +++ b/.github/workflows/publish-docker.yaml @@ -0,0 +1,60 @@ +name: Publish docker on GHCR + +on: + push: + branches: [main] + workflow_dispatch: + inputs: + force_docker_build: + description: 'Force Docker build (skip change detection)' + required: true + type: boolean + default: false + skip_docker_build: + description: 'Skip Docker build (use last built image)' + required: true + type: boolean + default: false + +jobs: + publish-docker: + name: Publish docker + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check if Docker build needed + id: changes + uses: dorny/paths-filter@v3 + with: + filters: | + docker: + - 'binder/Dockerfile' + - 'binder/environment.yaml' + + - name: Login to GitHub Container Registry + if: > + (!inputs.skip_docker_build) && + (inputs.force_docker_build || steps.changes.outputs.docker == 'true') + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build the Docker image + if: > + (!inputs.skip_docker_build) && + (inputs.force_docker_build || steps.changes.outputs.docker == 'true') + uses: docker/build-push-action@v6 + with: + context: . + tags: | + ghcr.io/pythonhealthdatascience/llm_simpy_models:latest + push: true + \ No newline at end of file From 58ec78e2a740b80e7a4f1f732b3b16348e8e5715 Mon Sep 17 00:00:00 2001 From: amyheather Date: Tue, 2 Dec 2025 11:18:07 +0000 Subject: [PATCH 3/5] docs(readme): add venv + docker instructions --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 657fdcb..edc071a 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ For a full record of the generation of these models, please refer to: https://gi ## 🌐 Creating the environment +### conda + The project uses `conda` to manage dependencies. Navigate your terminal to the directory containing the code and run: ``` @@ -51,7 +53,53 @@ This will create a conda environment called `gen_simpy_apps`. To activate: conda activate gen_simpy_apps ``` -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. +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. + +### venv + +Another option is to use `venv`. You can build the environment by running: + +``` +python -m venv venv +``` + +Then install the packages using: + +``` +pip install -r requirements.txt +``` + +`venv` cannot control which python version is used, it will just use one on system. You can check what this is by running: + +``` +venv/bin/python --version +``` + +You can find the version of python used for the models and app in the `binder/environment.yaml` file. + +### Docker + +Alternatively, a docker environment has been provided. + +You can build the image by running: + +``` +docker build -f binder/Dockerfile -t gen_simpy_apps . +``` + +Another option is to pull the image from the GitHub Container Registry: + +``` +docker pull ghcr.io/pythonhealthdatascience/llm_simpy_models:latest +``` + +Once you have the build image, you can then run the container: + +``` +docker run -p 8501:8501 gen_simpy_apps +``` + +Open your browser to to view the app.
From 445a392b4d64e947ec4c4d4d9c497f771472d2c2 Mon Sep 17 00:00:00 2001 From: amyheather Date: Tue, 2 Dec 2025 11:20:17 +0000 Subject: [PATCH 4/5] chore(v1.0.3): update changelog and citation.cff --- CHANGELOG.md | 13 +++++++++++++ CITATION.cff | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 927dbc9..fc6c591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 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). +## v1.0.3 - 2025-12-02 + +Add docker image and hosted on GitHub Container Registry. + +### Added + +* Add `Dockerfile` which builds conda environment and runs the app. +* Add GitHub action which builds Docker image and pushes to GitHub Container Registry. + +### Changed + +* Explained how to use Docker (and venv) in README. + ## v1.0.2 - 2025-03-25 Add note about `st.spinner()` to the home page. diff --git a/CITATION.cff b/CITATION.cff index a8bc246..c87aeda 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -29,5 +29,5 @@ repository-code: 'https://github.com/pythonhealthdatascience/llm_simpy_models' abstract: >- The SimPy models and apps generated by LLMs, deployed as a single app. license: MIT -version: '1.0.2' -date-released: '2025-03-25' \ No newline at end of file +version: '1.0.3' +date-released: '2025-12-02' \ No newline at end of file From 4fd369ceda60b8b5eaa84ed8bca7ceb055163fe6 Mon Sep 17 00:00:00 2001 From: amyheather Date: Tue, 2 Dec 2025 11:21:37 +0000 Subject: [PATCH 5/5] fix(ci-docker): correct "yaml" to "yml", and give path to Dockerfile when build --- .github/workflows/publish-docker.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml index 55cca2b..22e6946 100644 --- a/.github/workflows/publish-docker.yaml +++ b/.github/workflows/publish-docker.yaml @@ -35,7 +35,7 @@ jobs: filters: | docker: - 'binder/Dockerfile' - - 'binder/environment.yaml' + - 'binder/environment.yml' - name: Login to GitHub Container Registry if: > @@ -54,6 +54,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + file: binder/Dockerfile tags: | ghcr.io/pythonhealthdatascience/llm_simpy_models:latest push: true