Skip to content

Commit

Permalink
Merge pull request #2 from peterbull/arm
Browse files Browse the repository at this point in the history
misc updates for running locally on ARM
  • Loading branch information
peterbull authored Oct 18, 2024
2 parents 5b02316 + ecc06cd commit 8b68a4d
Show file tree
Hide file tree
Showing 11 changed files with 4,044 additions and 8,173 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,6 @@ airflow/mem-debug/vars.sh
firebase.json
firestore.indexes.json
firestore.rules
.firebaserc
.firebaserc

.DS_Store
36 changes: 22 additions & 14 deletions airflow/airflow.extension.dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
FROM apache/airflow:2.8.1

# Install additional dependencies for ECCODES


USER root
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg
RUN curl -fsSL https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor -o /etc/apt/keyrings/mariadb.gpg

# Install additional dependencies for ECCODES
RUN apt-get update --fix-missing && apt-get install -y libpq-dev gcc g++ wget \
libnetcdff-dev libopenjp2-7-dev gfortran make unzip git cmake \
&& mkdir /root/source_builds \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
libnetcdff-dev libopenjp2-7-dev gfortran make unzip git cmake \
libgdal-dev gdal-bin \
&& mkdir /root/source_builds \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /root
RUN mkdir -p source_builds/eccodes/build && mkdir -p /usr/src/eccodes

# Get ECCodes package
WORKDIR /root/source_builds/eccodes
RUN wget https://confluence.ecmwf.int/download/attachments/45757960/eccodes-2.31.0-Source.tar.gz?api=v2 && \
tar -xzf eccodes-2.31.0-Source.tar.gz?api=v2 && \
rm eccodes-2.31.0-Source.tar.gz?api=v2
tar -xzf eccodes-2.31.0-Source.tar.gz?api=v2 && \
rm eccodes-2.31.0-Source.tar.gz?api=v2

# Build ECCodes from source
WORKDIR /root/source_builds/eccodes/build
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/src/eccodes -DENABLE_JPG=ON ../eccodes-2.31.0-Source && \
make && \
ctest && \
make install && cp -r /usr/src/eccodes/bin/* /usr/bin
make && \
ctest && \
make install && cp -r /usr/src/eccodes/bin/* /usr/bin

# Export ECCodes Paths
ENV ECCODES_DIR=/usr/src/eccodes
ENV ECCODES_DEFINITION_PATH=/usr/src/eccodes/share/eccodes/definitions

RUN cp $ECCODES_DIR/lib/libeccodes.so /usr/lib && \
cp /usr/src/eccodes/include/* /usr/include/
cp /usr/src/eccodes/include/* /usr/include/

# Install and check for correct install with pthyon
RUN apt-get update && apt-get install -y python3-pip && \
pip3 install eccodes-python && \
python3 -m eccodes selfcheck
pip3 install eccodes-python && \
python3 -m eccodes selfcheck

# Install additional dependencies for project

USER airflow
WORKDIR /home/airflow

COPY airflow/requirements.txt .
RUN pip install -r requirements.txt
RUN pip install -r requirements.txt
4 changes: 3 additions & 1 deletion airflow/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cfgrib==0.9.10.4
confluent-kafka==2.3.0
eccodes==1.6.1
ecmwflibs==0.5.3
# ecmwflibs==0.5.3
# ecmwflibs
# climetlab[ecmwflibs]
GeoAlchemy2==0.14.3
xarray==2023.1.0
debugpy
Expand Down
1 change: 1 addition & 0 deletions backend/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.0
14 changes: 10 additions & 4 deletions backend/backend.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ FROM python:3.10.12-slim


# Install system dependencies required for psycopg2 and wget
RUN apt-get update && apt-get install -y libpq-dev gcc wget curl && \
RUN apt-get update && apt-get install -y libpq-dev gcc wget curl coreutils gdal-bin libgdal-dev g++ && \
rm -rf /var/lib/apt/lists/*

# Install Miniconda
ENV MINICONDA_VERSION=py310_24.1.2-0

# Uncomment this for building on ARM
ENV MINICONDA_ARCH=Linux-aarch64

# Typical x86 build env
# ENV MINICONDA_ARCH=Linux-x86_64
ENV CONDA_DIR=/opt/conda
ENV PATH=$CONDA_DIR/bin:$PATH

RUN wget https://repo.anaconda.com/miniconda/Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh \
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-$MINICONDA_VERSION-$MINICONDA_ARCH.sh \
&& mkdir -p $CONDA_DIR \
&& sh Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh -b -u -p $CONDA_DIR \
&& rm -f Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh
&& sh Miniconda3-$MINICONDA_VERSION-$MINICONDA_ARCH.sh -b -u -p $CONDA_DIR \
&& rm -f Miniconda3-$MINICONDA_VERSION-$MINICONDA_ARCH.

# Install cfgrib and eccodes using Conda, this is somewhat redudant,
# but the only way the cfgrib library installs correctly for xarray that I've found
Expand Down
5,268 changes: 2,777 additions & 2,491 deletions backend/poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ click = "^8.1.7"
geoalchemy2 = "^0.14.2"
pytest = "^7.4.4"
httpx = "^0.26.0"
watchdog = {extras = ["watchmedo"], version = "^3.0.0"}
watchdog = { extras = ["watchmedo"], version = "^3.0.0" }
odc-stac = "^0.3.8"
pystac-client = "^0.7.5"
jinja2 = "^3.1.2"
Expand All @@ -43,7 +43,7 @@ geopandas = "^0.14.3"
boto3 = "^1.34.49"
alembic = "^1.13.1"
nest-asyncio = "^1.6.0"

numpy = "^1.26.0, <2"


[tool.poetry.group.dev.dependencies]
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ services:
condition: service_healthy

postgres:
image: postgis/postgis:16-master
image: imresamu/postgis:16-3.4-bookworm
platform: linux/arm64
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
Expand Down
4 changes: 3 additions & 1 deletion frontend/my-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useEffect, useState } from "react";
import ComponentWrapper from "./components/ComponentWrapper";
import { ComponentMapProvider } from "./contexts/ComponentMapProvider";

//
//
function App() {
const [spots, setSpots] = useState([]);
const [zoom, setZoom] = useState(13);
Expand Down Expand Up @@ -45,7 +47,7 @@ function App() {
(now.getMonth() + 1).toString().padStart(2, "0") +
now.getDate().toString().padStart(2, "0");
const res = await fetch(
`${process.env.REACT_APP_BACKEND_URL}/forecasts/nearest/${date}/${currentSpot.latitude}/${currentSpot.longitude}`
`${process.env.REACT_APP_BACKEND_URL}/forecasts/nearest/${date}/${currentSpot.latitude}/${currentSpot.longitude}`,
);
const data = await res.json();
setSpotForecast(data);
Expand Down
Loading

0 comments on commit 8b68a4d

Please sign in to comment.