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
41 changes: 36 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🤓 GH Action 🚧
name: Python check

on:
workflow_call:
Expand All @@ -20,9 +20,40 @@ on:
# NOTE: For other, they should be run through helm github action ./helm-publish.yml

jobs:
pre_commit_checks:
name: Pre-Commit checks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main

- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: gdal-bin libgdal-dev

- name: Setup uv python environment
run: uv venv

- name: uv lock check
run: uv lock --locked --offline

- name: uv sync
run: uv sync --all-extras

- uses: pre-commit/action@main

build_test:
name: 🚴 Build + Test 🚴 # Match the name below (8398a7/action-slack).
name: Test
runs-on: ubuntu-latest
needs: pre_commit_checks

outputs:
docker_image_name: ${{ steps.prep.outputs.tagged_image_name }}
Expand Down Expand Up @@ -51,9 +82,9 @@ jobs:
if [[ "$BRANCH_NAME" == *"/"* ]]; then
# XXX: Change the docker image package to -alpha
IMAGE_NAME="$IMAGE_NAME-alpha"
TAG="$(echo "$BRANCH_NAME" | sed 's|/|-|g').$(echo $GITHUB_SHA | head -c7)"
TAG="$(echo "$BRANCH_NAME" | sed 's|/|-|g').c$(echo $GITHUB_SHA | head -c7)"
else
TAG="$BRANCH_NAME.$(echo $GITHUB_SHA | head -c7)"
TAG="$BRANCH_NAME.c$(echo $GITHUB_SHA | head -c7)"
fi

IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -122,7 +153,7 @@ jobs:
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

validate_helm:
name: 🚴 Validate Helm 🚴
name: Validate Helm
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Builds and pushes Docker Images and Helm charts to Github Registry
name: Helm publish

on:
workflow_dispatch:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/linting.yml

This file was deleted.

44 changes: 20 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
FROM python:3.8-slim-buster
FROM python:3.8-slim-bookworm AS base
COPY --from=ghcr.io/astral-sh/uv:0.7.4 /uv /uvx /bin/

LABEL maintainer="IFRC"
LABEL org.opencontainers.image.source="https://github.com/IFRCGo/go-risk-module-api"

ENV PYTHONUNBUFFERED=1

ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_PROJECT_ENVIRONMENT="/usr/local/"

WORKDIR /code

RUN apt-get -y update \
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
apt-get update -y \
&& apt-get install -y --no-install-recommends \
git \
g++ \
curl \
wait-for-it \
gdal-bin \
libgdal-dev


ARG CPLUS_INCLUDE_PATH=/usr/include/gdal
ARG C_INCLUDE_PATH=/usr/include/gdal
RUN pip install GDAL==2.4.0

COPY pyproject.toml poetry.lock /code/

# Upgrade pip and install python packages for code
RUN pip install --upgrade --no-cache-dir pip poetry \
&& poetry --version \
# Configure to use system instead of virtualenvs
&& poetry config virtualenvs.create false \
&& poetry install --no-root \
# Remove installer
&& pip uninstall -y poetry virtualenv-clone virtualenv
# Build required packages
gdal-bin build-essential gcc g++ libc-dev libgdal-dev libproj-dev \
# Helper packages
git curl wait-for-it procps \
&& uv lock --locked --offline \
&& uv sync --frozen --no-install-project --all-groups \
# Clean-up
&& apt-get remove -y build-essential gcc g++ libc-dev libgdal-dev libproj-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*


COPY . /code/
Loading
Loading