Skip to content

Commit

Permalink
Deploy back & front end (#217)
Browse files Browse the repository at this point in the history
* chore: move packaging to uv

* feat: migration Docker pour uv python 3.10

---------

Co-authored-by: herve.le-bars <[email protected]>
  • Loading branch information
SaboniAmine and herve.le-bars authored Nov 2, 2024
1 parent f0f2a47 commit 1d9bf02
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 65 deletions.
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ well as policy-makers and economic stakeholders.

Bloom is tested with:

| | Main version (dev) | Stable version (1.0.0) |
|------------|----------------------|------------------------|
| Python | 3.8, 3.9, 3.10, 3.11 | 3.8, 3.9, 3.10, 3.11 |
| Platform | AMD64/ARM64(\*) | AMD64/ARM64(\*) |
| Docker | 24 | 24 |
| PostgreSQL | 14 | 14 |
| | Main version (dev) | Stable version (1.0.0) |
|------------|--------------------|------------------------|
| Python | 3.11 | 3.11 |
| Platform | AMD64/ARM64(\*) | AMD64/ARM64(\*) |
| Docker | 24 | 24 |
| PostgreSQL | 14 | 14 |

## Getting started

Expand Down Expand Up @@ -118,7 +118,7 @@ You can now jump to [Use the Bloom Application](#use-the-bloom-application)

#### Prerequistes

* **Python**: 3.9, 3.10, 3.11
* **Python**: 3.11
* **Python-pip**: >=20
* **Postgresql**: 14, 15, 16

Expand All @@ -130,18 +130,10 @@ password, database name, port to use)
```bash
# From project diretory
cd ./backend
# Install poetry
pip install --user "poetry==1.8.1"
# Mise à disposition de l'exécutable de manière temporaire
export PATH=$PATH:~/.local/bin/
# Ensure that poetry will create a `.venv` directory into the project with the command
poetry config virtualenvs.in-project true
# Install dependencies from pyproject.toml
poetry install
# Make sure everything is all right using
poetry env info
# Enable virtual poetry project environment
poetry shell
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install project and dependencies
uv sync
```

#### Initial configuration
Expand Down
87 changes: 48 additions & 39 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry]
[tool.hatch.build.targets.wheel]
packages = ["bloom"]


[dependency-groups]
dev = [
"pre-commit~=3.6",
"ruff~=0.7",
"tox~=4.14",
]

[project]
authors = [
{name = "Your Name", email = "[email protected]"},
]
requires-python = "~=3.10"
dependencies = [
"alembic~=1.13",
"autopep8~=2.3",
"dependency-injector~=4.42",
"dependency-injection~=1.2",
"GeoAlchemy2~=0.15",
"geopandas~=0.14",
"geopy~=2.4",
"gql~=3.5",
"matplotlib~=3.9",
"openpyxl~=3.1",
"pandas~=2.2",
"poetry~=1.8",
"psycopg2-binary~=2.9",
"pydantic~=2.9",
"pydantic-settings~=2.6",
"python-dotenv~=1.0",
"PyYAML~=6.0",
"requests~=2.32",
"requests-toolbelt~=1.0",
"shapely~=2.0",
"scipy==1.12.0",
"slack-sdk~=3.33",
"SQLAlchemy~=2.0",
"pycountry==23.12.11",
"fastapi[standard]>=0.115.0,<1.0.0",
"uvicorn~=0.32",
"redis~=5.0",
]
name = "bloom"
version = "0.1.0"
description = "Bloom scrapping application"
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
alembic = "~1.13"
autopep8 = "~2.0"
dependency-injector = "~4.41"
dependency_injection = "~1.2"
GeoAlchemy2 = "~0.14"
geopandas = "~0.14"
geopy = "~2.4"
gql = "~3.5"
matplotlib = "~3.8"
openpyxl = "~3.1"
pandas = "~2.2"
poetry = "~1.8"
psycopg2-binary = "~2.9"
pydantic = "~2.6"
pydantic-settings = "~2.2"
python = ">=3.9,<3.9.7 || >3.9.7,<4.0"
python-dotenv = "~1.0"
PyYAML = "~6.0"
requests = "~2.31"
requests-toolbelt = "~1.0"
shapely = "~2.0"
scipy = "1.12.0"
slack-sdk = "~3.27"
SQLAlchemy = "~2.0"
pycountry = "23.12.11"
fastapi = "^0.111.0"
uvicorn = "^0.30.1"
redis = "^5.0.4"


[tool.poetry.group.dev.dependencies]
pre-commit = "~3.6"
ruff = "~0.3"
tox = "~4.14"

[tool.ruff]
select = [
"A",
Expand Down Expand Up @@ -148,3 +156,4 @@ target-version = "py310"

[tool.ruff.mccabe]
max-complexity = 10

3 changes: 3 additions & 0 deletions clevercloud/clever.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"*/15 * * * * /home/bas/venv/bin/python /home/bas/app_7244f095-70bc-43c3-9950-d075c01af05f/backend/load_spire_data_from_api.py"
]
23 changes: 16 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ RUN apt-get update &&\
apt-get -y install curl &&\
apt-get install -y rsyslog &&\
apt-get install -y libgdal-dev &&\
apt-get install -y g++
apt-get install -y g++ &&\
apt-get install -y clang


# Define working directory
ARG VIRTUAL_ENV=/.venv
ENV PATH=${VIRTUAL_ENV}/bin:$PATH \
VIRTUAL_ENV=${VIRTUAL_ENV}
ARG PROJECT_DIR=/project
ENV PROJECT_DIR=${PROJECT_DIR}
WORKDIR ${PROJECT_DIR}
Expand All @@ -23,14 +27,19 @@ ARG POETRY_VERSION=1.8.2
ENV POETRY_VERSION=${POETRY_VERSION}
RUN pip install --upgrade pip && pip install --user "poetry==$POETRY_VERSION"
ENV PATH="${PATH}:/root/.local/bin"
COPY ./backend/pyproject.toml ./backend/poetry.lock ./backend/alembic.ini ./backend/
COPY ./backend/pyproject.toml ./backend/alembic.ini ./backend/

ENV PATH=/venv/bin:$PATH \
VIRTUAL_ENV=/venv
RUN python -m venv /venv &&\
echo ". /venv/bin/activate" >> /root/.bashrc &&\

# Install UV
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ARG UV_PROJECT_ENVIRONMENT=${VIRTUAL_ENV}
ENV UV_PROJECT_ENVIRONMENT=${VIRTUAL_ENV}
RUN \
. ~/.cargo/env &&\
cd backend &&\
poetry install
uv venv ${VIRTUAL_ENV} &&\
echo ". ${VIRTUAL_ENV}/bin/activate" >> /root/.bashrc &&\
uv sync

# Launch cron services
RUN DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install -y cron \
Expand Down

0 comments on commit 1d9bf02

Please sign in to comment.