Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Container

on:
push:
branches:
- main
tags:
- "v*"
pull_request:
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
build-and-push:
name: Build and push image
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GitHub Container Registry
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Comment thread
elbdmi marked this conversation as resolved.
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract image metadata
id: meta
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Comment thread
elbdmi marked this conversation as resolved.
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository_owner }}/sunflow
tags: |
type=ref,event=tag
type=raw,value=latest

- name: Build image (push on version tags)
uses: docker/build-push-action@v7
with:
context: .
file: ./ContainerFile
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
Comment thread
elbdmi marked this conversation as resolved.
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added pre-commit configuration for linting and formatting [!6](https://github.com/dmidk/sunflow/pull/6), @khintz
- Add build and publish container workflow [!8](https://github.com/dmidk/sunflow/pull/8), @khintz

### Changed

Expand Down
14 changes: 8 additions & 6 deletions ContainerFile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM dockerhub.com/python:3.12
FROM python:3.12

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -14,15 +14,16 @@ RUN apt-get update -y && \
libhdf5-dev \
libnetcdf-dev \
pkg-config \
git && \
git \
curl && \
rm -rf /var/lib/apt/lists/*

# Set up container environment
ENV USER_ID=1000
ENV GROUP_ID=1000

# Install Python package manager
RUN pip install -U pip setuptools wheel pdm
# Install uv for fast dependency resolution and installation
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
Comment thread
elbdmi marked this conversation as resolved.

ENV PATH="${PATH}:/root/.local/bin"

Expand All @@ -32,11 +33,12 @@ WORKDIR /project

# Copy project files
COPY pyproject.toml /project/
COPY uv.lock /project/
COPY sunflow/ /project/sunflow/
COPY README.md /project/
COPY config.yaml /project/

# Install project dependencies
RUN pdm venv create && pdm install
RUN uv sync --frozen --no-dev

ENTRYPOINT ["pdm", "run", "python", "-m", "sunflow.main"]
ENTRYPOINT ["uv", "run", "python", "-m", "sunflow.main"]
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ cd sunflow
To contribute, fork the repository first — see [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow.

## Local development
This project uses [pdm](https://pdm.fming.dev/latest/) for dependency management.
Other package managers, such as [uv](https://docs.astral.sh/uv/getting-started/), also work.
`pdm` can be installed with:
This project uses [uv](https://docs.astral.sh/uv/getting-started/) for dependency management.

`uv` can be installed with:

```shell
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
curl -LsSf https://astral.sh/uv/install.sh | sh
```

After this you can create a virtualenv and install `sunflow` with

```shell
pdm venv create
pdm install
uv sync
```

The suite can then be run by
```shell
pdm run sunflow
uv run sunflow
```
or, after activating the virtualenv (`source .venv/bin/activate`):
```shell
Expand All @@ -51,6 +50,13 @@ sunflow
podman build -f ContainerFile -t sunflow .
```

GitHub Actions builds the container on pushes to `main` and on pull requests.
Publishing to ghcr.io happens only for version tags (`v*`), with tags like `v1.2.3` and `latest`, as:

```text
ghcr.io/dmidk/sunflow
```

### Running the Container

To start a basic run, simply type the command below. This will start the default behavior where the script awaits the data and does the nowcasting when the data becomes available.
Expand Down Expand Up @@ -143,5 +149,5 @@ podman run -it --rm --entrypoint="" sunflow bash
## Installing locally
Building pysteps can sometimes fail if a pre-built wheel is not available for your Python version. If the environment variables `CC` and `CXX` are not set, building pysteps falls back to clang, which may only work on Intel-based macOS. To use GNU compilers instead:
```shell
CC=gcc CXX=g++ pdm install
CC=gcc CXX=g++ uv sync
```
Loading
Loading