Skip to content

Commit 0cec0be

Browse files
Aleksandar Tomčićfedjoarrudavlf-stefan-drobic
authored
Sync from open-agri repo (#69)
* Sync changes from upstream (#13) * Enhance README with examples for analysis documentation Updated documentation to include working examples for evapotraspiration and soil analysis. Signed-off-by: fedjo <mari.giorgos@gmail.com> * readme update (#63) --------- Signed-off-by: fedjo <mari.giorgos@gmail.com> Co-authored-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> * Feat/irrigation datapoints (#14) * update dataset scheme * first test * new test added * update readme with testing section * new api for irrigation datapoints added * refactoring on datapoints * readme update with new API --------- Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> * adding arm64 build (#15) no branch name as workflow input * Update README.md (#16) Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> * Feat/eto improvement (#17) * feat: add koefs to ETo calculations * bug fix * added new migration file * API for fething options added --------- Co-authored-by: Stefan <stefan.drobic@vizlore.com> * Update eto.py (#19) Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> * Feat/soil analysis improvement (#18) * suggest stress fraction function added * input for field capacity and wilting point added * irrigation datapoins update acording to new version of soil analysis * bug fix * introducing new migrations * soil types GET api added * fix for db migration head * migration fix and soil types priorites fixed * volumes added * migration ordering fixed * Update compose.yaml Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> --------- Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> Co-authored-by: Stefan <stefan.drobic@vizlore.com> --------- Signed-off-by: fedjo <mari.giorgos@gmail.com> Signed-off-by: Aleksandar Tomčić <aleksandar.tomcic@vizlore.com> Co-authored-by: fedjo <mari.giorgos@gmail.com> Co-authored-by: Felipe Arruda Pontes <felipe.arrudapontes@maastrichtuniversity.nl> Co-authored-by: Stefan <stefan.drobic@vizlore.com>
1 parent 04f6374 commit 0cec0be

20 files changed

Lines changed: 622 additions & 46 deletions

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#build
2+
TAG=latest
3+
DOCKER_REGISTRY=openagri-eu
4+
SOURCE_REPO=https://github.com/openagri-eu/openagri-irrigationmanagement
5+
#
16
# DB
27
POSTGRES_USER=my_user_name
38
POSTGRES_PASSWORD=my_password
@@ -32,4 +37,4 @@ GATEKEEPER_PASSWORD=gatekeeper_password
3237
SERVICE_NAME=irrigation
3338

3439
# Frontend
35-
USING_FRONTEND=False
40+
USING_FRONTEND=False

.github/workflows/docker-image.yml

Lines changed: 106 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
name: Docker Image CI
1+
name: Docker Multi-Platform Builds
22

33
on:
44
push:
55
branches: [ main ]
66
workflow_dispatch:
7-
inputs:
8-
branch:
9-
description: 'Branch to run the workflow on'
10-
required: false
117
release:
12-
types:
13-
- created
8+
types: [ created ]
149

1510
jobs:
16-
build-and-push:
11+
12+
# -------------------------
13+
# AMD64 Build
14+
# -------------------------
15+
build-amd64:
1716
runs-on: ubuntu-latest
1817
permissions:
1918
contents: read
2019
packages: write
21-
2220
steps:
2321
- name: Checkout code
2422
uses: actions/checkout@v4
25-
with:
26-
fetch-depth: 0 # Saves time by not fetching other branches
2723

2824
- name: Set up Docker Buildx
2925
uses: docker/setup-buildx-action@v3
@@ -35,16 +31,111 @@ jobs:
3531
username: ${{ github.repository_owner }}
3632
password: ${{ secrets.GITHUB_TOKEN }}
3733

38-
- name: Set lowercase repository name
34+
- name: Normalize repo and sanitize ref
3935
run: |
4036
echo "REPO_LOWER=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
37+
SAFE_REF=$(echo "${GITHUB_REF_NAME}" | tr / -)
38+
echo "SAFE_REF=$SAFE_REF" >> $GITHUB_ENV
4139
42-
- name: Build and push Docker image
43-
id: docker_build
40+
- name: Build and push AMD64 image
4441
uses: docker/build-push-action@v6
4542
with:
4643
context: .
44+
file: Dockerfile
45+
build-args: SOURCE_REPO=https://github.com/${{ github.repository }}
46+
platforms: linux/amd64
4747
push: true
48-
tags: ghcr.io/${{ env.REPO_LOWER }}:latest
48+
tags: |
49+
ghcr.io/${{ env.REPO_LOWER }}:${{ env.SAFE_REF }}-amd64
50+
${{ github.ref_name == 'main' && format('ghcr.io/{0}:latest-amd64', env.REPO_LOWER) || '' }}
4951
cache-from: type=gha
5052
cache-to: type=gha,mode=max
53+
54+
# -------------------------
55+
# ARM64 Build
56+
# -------------------------
57+
build-arm64:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Docker daemon (containerd features)
64+
uses: docker/setup-docker-action@v4
65+
with:
66+
daemon-config: |
67+
{
68+
"debug": true,
69+
"features": { "containerd-snapshotter": true }
70+
}
71+
72+
- name: Set up QEMU
73+
uses: docker/setup-qemu-action@v3
74+
75+
- name: Set up Docker Buildx
76+
uses: docker/setup-buildx-action@v3
77+
78+
- name: Login to GitHub Container Registry
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.repository_owner }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Normalize repo and sanitize ref
86+
run: |
87+
echo "REPO_LOWER=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
88+
SAFE_REF=$(echo "${GITHUB_REF_NAME}" | tr / -)
89+
echo "SAFE_REF=$SAFE_REF" >> $GITHUB_ENV
90+
91+
- name: Build and push ARM64 image
92+
uses: docker/build-push-action@v6
93+
with:
94+
context: .
95+
file: Dockerfile
96+
build-args: BUILDKIT_PROGRESS=plain,SOURCE_REPO=https://github.com/${{ github.repository }}
97+
platforms: linux/arm64
98+
push: true
99+
tags: |
100+
ghcr.io/${{ env.REPO_LOWER }}:${{ env.SAFE_REF }}-arm64
101+
${{ github.ref_name == 'main' && format('ghcr.io/{0}:latest-arm64', env.REPO_LOWER) || '' }}
102+
cache-from: type=gha,scope=arm64
103+
cache-to: type=gha,scope=arm64,mode=max
104+
105+
# -------------------------
106+
# Create multi-arch manifest
107+
# -------------------------
108+
manifest:
109+
needs: [ build-amd64, build-arm64 ]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Set up Docker Buildx (for imagetools)
113+
uses: docker/setup-buildx-action@v3
114+
115+
- name: Login to GitHub Container Registry
116+
uses: docker/login-action@v3
117+
with:
118+
registry: ghcr.io
119+
username: ${{ github.repository_owner }}
120+
password: ${{ secrets.GITHUB_TOKEN }}
121+
122+
- name: Normalize repo and sanitize ref
123+
run: |
124+
echo "REPO_LOWER=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
125+
SAFE_REF=$(echo "${GITHUB_REF_NAME}" | tr / -)
126+
echo "SAFE_REF=$SAFE_REF" >> $GITHUB_ENV
127+
128+
- name: Create multi-arch manifest for ref tag
129+
run: |
130+
docker buildx imagetools create \
131+
--tag ghcr.io/${{ env.REPO_LOWER }}:${{ env.SAFE_REF }} \
132+
ghcr.io/${{ env.REPO_LOWER }}:${{ env.SAFE_REF }}-amd64 \
133+
ghcr.io/${{ env.REPO_LOWER }}:${{ env.SAFE_REF }}-arm64
134+
135+
- name: Also tag :latest on main
136+
if: ${{ github.ref_name == 'main' }}
137+
run: |
138+
docker buildx imagetools create \
139+
--tag ghcr.io/${{ env.REPO_LOWER }}:latest \
140+
ghcr.io/${{ env.REPO_LOWER }}:latest-amd64 \
141+
ghcr.io/${{ env.REPO_LOWER }}:latest-arm64

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
ARG SOURCE_REPO=https://github.com/openagri-eu/openagri-irrigationmanagement
12
FROM python:3.12
3+
LABEL org.opencontainers.image.source=${SOURCE_REPO}
24

35
# Set environment variables
46
ENV PYTHONDONTWRITEBYTECODE=1
@@ -31,4 +33,4 @@ COPY . /code
3133

3234
COPY entrypoint.sh /usr/local/bin/
3335

34-
RUN chmod +x /usr/local/bin/entrypoint.sh
36+
RUN chmod +x /usr/local/bin/entrypoint.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This service uses FastAPI as a web framework to serve APIs, alembic for database
5959

6060
<h3> Deploying via docker </h3>
6161

62-
After installing <code>docker-compose</code> you can run the following commands to run the application:
62+
After installing <code>docker compose</code> you can run the following commands to run the application:
6363

6464
```
6565
docker compose build
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""test
2+
3+
Revision ID: 7c78a3ccee81
4+
Revises: b16fbe93d8a3
5+
Create Date: 2026-01-15 15:33:01.165654
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '7c78a3ccee81'
16+
down_revision: Union[str, None] = 'b16fbe93d8a3'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.create_table('crop_kc',
24+
sa.Column('crop', sa.String(), nullable=False),
25+
sa.Column('kc_init', sa.Float(), nullable=False),
26+
sa.Column('kc_mid', sa.Float(), nullable=False),
27+
sa.Column('kc_end', sa.Float(), nullable=False),
28+
sa.PrimaryKeyConstraint('crop'),
29+
sa.UniqueConstraint('crop')
30+
)
31+
32+
33+
def downgrade() -> None:
34+
# ### commands auto generated by Alembic - please adjust! ###
35+
op.drop_table('crop_kc')
36+
# ### end Alembic commands ###
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""Add soil_type_values table
2+
3+
Revision ID: b16fbe93d8a3
4+
Revises: 232f37fc06a1
5+
Create Date: 2026-01-14 15:59:06.756518
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = 'b16fbe93d8a3'
16+
down_revision: Union[str, None] = '232f37fc06a1'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.create_table('soil_type_values',
24+
sa.Column('soil_type', sa.String(), nullable=False),
25+
sa.Column('field_capacity', sa.Float(), nullable=False),
26+
sa.Column('wilting_point', sa.Float(), nullable=False),
27+
sa.PrimaryKeyConstraint('soil_type'),
28+
sa.UniqueConstraint('soil_type')
29+
)
30+
op.create_unique_constraint(None, 'eto', ['id'])
31+
op.create_unique_constraint(None, 'location', ['id'])
32+
op.drop_column('location', 'state_code')
33+
op.drop_column('location', 'city_name')
34+
op.drop_column('location', 'country_code')
35+
op.create_unique_constraint(None, 'user', ['id'])
36+
# ### end Alembic commands ###
37+
38+
39+
def downgrade() -> None:
40+
# ### commands auto generated by Alembic - please adjust! ###
41+
op.drop_constraint(None, 'user', type_='unique')
42+
op.add_column('location', sa.Column('country_code', sa.VARCHAR(), autoincrement=False, nullable=True))
43+
op.add_column('location', sa.Column('city_name', sa.VARCHAR(), autoincrement=False, nullable=True))
44+
op.add_column('location', sa.Column('state_code', sa.VARCHAR(), autoincrement=False, nullable=True))
45+
op.drop_constraint(None, 'location', type_='unique')
46+
op.drop_constraint(None, 'eto', type_='unique')
47+
op.drop_table('soil_type_values')
48+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)