-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use poetry and update docker configurations
- Loading branch information
Showing
26 changed files
with
3,616 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# this file is only used to build the frontend image | ||
# NOT for the python api (see api/.dockerignore for that) | ||
common/node_modules/** | ||
frontend/node_modules/** | ||
alerting/* | ||
api/* | ||
docs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# for comment on PR, follow instruction for: https://github.com/marketplace/actions/sticky-pull-request-comment | ||
name: PRISM CI - API | ||
on: | ||
# Run on all pull requests and on pushes to master. | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
api_lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
# run the matrix jobs one after the other, so they can benefit from caching | ||
max-parallel: 1 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
# Version of Poetry to use | ||
version: 1.6.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
- name: Install dependencies | ||
run: | | ||
cd api | ||
poetry install | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
- name: Check formatting with black and isort | ||
run: | | ||
cd api | ||
poetry run black --check . | ||
poetry run isort --check . | ||
api_build: | ||
name: build and test api | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Docker Compose | ||
run: | | ||
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | ||
mkdir -p $DOCKER_CONFIG/cli-plugins | ||
curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-`uname -s`-`uname -m` -o $DOCKER_CONFIG/cli-plugins/docker-compose | ||
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | ||
docker compose version | ||
- name: Build containers | ||
run: cd api && make build | ||
- name: Run tests | ||
run: cd api && make api-test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,51 @@ | ||
# only image with python 3.10 on it | ||
# other GDAL images use python 3.8 | ||
# This provides GDAL 3.6dev | ||
FROM osgeo/gdal:ubuntu-small-latest | ||
FROM ghcr.io/osgeo/gdal:ubuntu-full-3.7.0 | ||
|
||
COPY ./app /app | ||
ENV PYTHONPATH=/ | ||
|
||
WORKDIR /app/ | ||
ENV POETRY_VERSION=1.6.1 | ||
# install poetry in this location | ||
ENV POETRY_HOME="/opt/poetry" | ||
|
||
ENV PYTHONPATH=/ | ||
# do not ask any interactive question | ||
ENV POETRY_NO_INTERACTION=1 | ||
# set the cache location so we can mount docker buildx cache on it | ||
ENV POETRY_CACHE_DIR=/root/.cache | ||
|
||
# set poetry to use the system python env so we get all | ||
# the GDAL packages which are already installed. This goes | ||
# against best practice, but follows the logic in place before | ||
# the switch to poetry | ||
ENV POETRY_VIRTUALENVS_CREATE=false | ||
|
||
ENV PATH="$POETRY_HOME/bin:$PATH" | ||
|
||
RUN --mount=type=cache,target=/root/.cache curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
COPY requirements.txt . | ||
# COPY requirements.txt . | ||
# copy pyproject so that black and isort use the right config | ||
COPY pyproject.toml / | ||
|
||
RUN apt update | ||
RUN apt install -y python3-pip libpq-dev | ||
COPY poetry.lock / | ||
|
||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
apt-get update && \ | ||
apt-get --no-install-recommends install -y python3-pip libpq-dev curl python3-dev build-essential | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
RUN playwright install chromium | ||
RUN playwright install-deps | ||
|
||
RUN --mount=type=cache,target=/root/.cache \ | ||
poetry install | ||
|
||
# RUN --mount=type=cache,target=/root/.cache poetry run playwright install chromium | ||
RUN poetry run playwright install chromium | ||
# playwright installs a lot of apt packages | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/var/lib/apt \ | ||
--mount=type=cache,target=/var/cache/apt \ | ||
poetry run playwright install-deps | ||
|
||
# keep this copy towards the end to help with caching previous layers | ||
COPY ./app /app | ||
|
||
WORKDIR /app/ | ||
|
||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.