Skip to content

Commit f0a32c5

Browse files
authored
Merge pull request #56 from NathanPB/peerless-paralelization-fix
Various fixes for Pythia
2 parents 0bc4be3 + 8bf58eb commit f0a32c5

File tree

11 files changed

+1042
-919
lines changed

11 files changed

+1042
-919
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.dockerignore
2+
.venv

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'New version'
8+
required: true
9+
10+
jobs:
11+
update-and-build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out the repo
15+
uses: actions/checkout@v2
16+
17+
- name: Update pyproject.toml version
18+
run: |
19+
sed -i "s/^version = .*/version = \"${{ github.event.inputs.version }}\"/" pyproject.toml
20+
git config --global user.name 'GitHub Actions'
21+
git config --global user.email '[email protected]'
22+
git commit -am "ci: Version bump ${{ github.event.inputs.version }}"
23+
git push
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@v1
30+
with:
31+
username: ${{ vars.DOCKER_USERNAME }}
32+
password: ${{ secrets.DOCKER_TOKEN }}
33+
34+
- name: Build and push Docker Image
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: .
38+
file: ./Dockerfile
39+
platforms: linux/amd64 #,linux/arm64 future ;)
40+
push: true
41+
tags: ${{ vars.DOCKER_IMAGE_NAME }}:${{ github.event.inputs.version }}, ${{ secrets.DOCKER_IMAGE_NAME }}:latest
42+
43+
- name: Push version bump commit
44+
run: |
45+
git tag ${{ github.event.inputs.version }}
46+
git push origin ${{ github.event.inputs.version }}
47+
git push
48+
49+
- name: Create GitHub Release
50+
uses: actions/create-release@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
tag_name: ${{ github.event.inputs.version }}
55+
release_name: Release ${{ github.event.inputs.version }}
56+
draft: false
57+
prerelease: false

Dockerfile

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1-
FROM dssat/dssat-csm
1+
FROM dssat/dssat-csm:v4.8.2.0
22

3-
COPY . /app/pythia
4-
RUN ln -sf /bin/bash /bin/sh && \
5-
# install pre-reqs for pyenv installed pythons
6-
apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
7-
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
8-
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git libspatialindex-dev && \
9-
# setup pyenv
10-
curl https://pyenv.run | bash && \
11-
echo 'export PATH="/root/.pyenv/bin:/root/.local/bin:$PATH"' >> ~/.bashrc && \
12-
echo 'eval "$(pyenv init -)"' >> ~/.bashrc && \
13-
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc && \
14-
export PATH="/root/.pyenv/bin:/root/.local/bin:$PATH" && \
15-
eval "$(pyenv init -)" && \
16-
eval "$(pyenv virtualenv-init i)" && \
17-
# install python 3.7.9
18-
pyenv install 3.7.9 && \
19-
pyenv rehash && \
20-
pyenv virtualenv 3.7.9 pythia-3.7.9 && \
21-
pyenv activate pythia-3.7.9 && \
22-
pip install --upgrade pip && \
23-
pip install pipenv && \
24-
# install dependencies
25-
cd /app/pythia && \
26-
pipenv install && \
27-
echo "#!/bin/bash" > /app/pythia.sh && \
28-
echo "" >> /app/pythia.sh && \
29-
echo 'export PATH="/root/.pyenv/bin:/root/.local/bin:$PATH"' >> /app/pythia.sh && \
30-
echo 'export PYENV_VIRTUALENV_DISABLE_PROMPT=1' >> /app/pythia.sh && \
31-
echo 'eval "$(pyenv init -)"' >> /app/pythia.sh && \
32-
echo 'eval "$(pyenv virtualenv-init -)"' >> /app/pythia.sh && \
33-
echo "pyenv activate pythia-3.7.9" >> /app/pythia.sh && \
34-
echo "python /app/pythia/pythia.py \$@" >> /app/pythia.sh && \
35-
echo "pyenv deactivate" && \
36-
chmod 755 /app/pythia.sh
3+
RUN apt-get update && apt-get install -y \
4+
python3.11 \
5+
python3.11-dev \
6+
python3-pip \
7+
python3-venv \
8+
python3-poetry \
9+
python3-virtualenv \
10+
curl \
11+
gdal-bin=3.6.2+dfsg-1+b2 \
12+
libgdal-dev=3.6.2+dfsg-1+b2 \
13+
&& rm -rf /var/lib/apt/lists/*
3714

38-
ENTRYPOINT ["/app/pythia.sh"]
39-
CMD ["-h"]
15+
ENV GDAL_VERSION 3.6.2
16+
ENV C_INCLUDE_PATH=/usr/include/python3.11/cpython
17+
ENV CPLUS_INCLUDE_PATH=/usr/include/python3.11/cpython
18+
19+
WORKDIR /app/pythia
20+
21+
COPY pyproject.toml poetry.toml poetry.lock ./
22+
RUN POETRY_VIRTUALENVS_CREATE=false poetry install --no-interaction --no-ansi
23+
24+
COPY . ./
25+
ENV PATH="${PATH}:/app/pythia/bin"
26+
27+
ENTRYPOINT ["pythia"]

bin/pythia

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

3-
python -m pythia $@
3+
source .venv/bin/activate
4+
python3 -m pythia $@

0 commit comments

Comments
 (0)