Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Revert use of search endpoint #370

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
28 changes: 17 additions & 11 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ jobs:
run: |
echo "DOCKER_IMAGE=${DOCKER_IMAGE_BASENAME}:$IMAGE_TAG" >> $GITHUB_ENV

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get image name
run: |
VERSION=${GITHUB_REF#refs/*/}
Expand All @@ -53,9 +47,21 @@ jobs:
fi
echo "DOCKER_IMAGE=$DOCKER_IMAGE_BASENAME:$IMAGE_TAG" >> $GITHUB_ENV

- run: docker build --label "org.label-schema.vcs-ref=$GITHUB_SHA" -t $DOCKER_IMAGE .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker push
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
docker push $DOCKER_IMAGE
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
tags: ${{ env.DOCKER_IMAGE }}
labels: org.label-schema.vcs-ref=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

- uses: actions/checkout@v2

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- name: Display Python version
run: python -c "import sys; print(sys.version)"
Expand Down
83 changes: 1 addition & 82 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,87 +60,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
# Not disabled in default config
broad-except,
disable=broad-except,
consider-using-get,
dangerous-default-value,
global-statement,
Expand All @@ -164,7 +84,6 @@ disable=print-statement,
# NOTE: Doesn't operate well with pydantic's decorator `validator`
# https://github.com/samuelcolvin/pydantic/issues/568
no-self-argument,
no-self-use,
# NOTE: Reports false positive with assignment expression
# https://github.com/PyCQA/pylint/issues/3249
superfluous-parens,
Expand Down
64 changes: 46 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
FROM python:3.8-slim
# ---
# --- Builder image
# ---

RUN apt-get update && apt-get -y install git gcc
FROM python:3.10-alpine as builder

RUN useradd -r app_user
RUN mkdir /app
RUN chown app_user /app/
WORKDIR /app
# Install build dependancies
RUN apk update && apk add --upgrade --no-cache g++ make

# Installing packages
RUN pip install pipenv==2018.11.26
# Install pipenv
RUN pip install --no-cache-dir --upgrade pip
RUN pip install pipenv

ADD --chown=app_user app.py Pipfile* /app/
RUN pipenv install --system --deploy
WORKDIR /usr/local/src

USER app_user
# Build a venv with dependancies in current directory
COPY Pipfile.lock Pipfile* /usr/local/src/
RUN PIPENV_VENV_IN_PROJECT=1 pipenv sync

# the sources are copied as late as possible since they are likely to change often
ADD --chown=app_user idunn /app/idunn
# ---
# --- Application image
# ---

# set the multiprocess mode for gunicorn
FROM python:3.10-alpine as runtime

# Create the user idunn
RUN addgroup --gid 1000 idunn
RUN adduser --disabled-password --home /home/idunn --ingroup idunn \
--uid 1000 idunn

ENV PYTHONUNBUFFERED=1

# Set the multiprocess mode for gunicorn
ENV IDUNN_PROMETHEUS_MULTIPROC=1
ENV PROMETHEUS_MULTIPROC_DIR=/app/idunn/prometheus_multiproc
RUN mkdir /app/idunn/prometheus_multiproc
ENV PROMETHEUS_MULTIPROC_DIR=/home/idunn/prometheus_multiproc

# Install lib dependancies
RUN apk update && apk add --upgrade --no-cache geos

USER idunn
WORKDIR /home/idunn
RUN mkdir -p /home/idunn/prometheus_multiproc

# Add files into images
COPY app.py /home/idunn
COPY idunn /home/idunn/idunn
COPY --from=builder /usr/local/src/.venv /home/idunn/.venv

EXPOSE 5000

# You can set the number of workers by passing --workers=${NB_WORKER} to the docker run command.
# For some reason, an array is required here to accept other params on run.
ENTRYPOINT ["gunicorn", "app:app", "--bind=0.0.0.0:5000", "--pid=/tmp/gunicorn.pid", \
"-k", "uvicorn.workers.UvicornWorker", "--preload"]
ENTRYPOINT [ \
"./.venv/bin/python", "-m", "gunicorn", "app:app", \
"--bind=0.0.0.0:5000", \
"--pid=/tmp/gunicorn.pid", \
"-k", "uvicorn.workers.UvicornWorker", \
"--preload" \
]
14 changes: 6 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ lint-tests = """pipenv run pylint tests --disable='consider-using-with, \

[dev-packages]
pytest = "*"
pytest-asyncio = "*"
lovely-pytest-docker = "*"
freezegun = "*"
ipython = "*"
responses = "*"
black = "==20.8b1"
black = "22.3.0"
respx = "*"
pylint = "*"

[packages]
fastapi="==0.65.*"
fastapi="==0.78.*"
elasticsearch2 = ">=2.0.0,<3.0.0"
elasticsearch = "==7.15.1"
requests = ">=2.20.0"
elasticsearch = "==7.16.3"
requests = "*"
tzwhere = "*"
babel = "*"
pybreaker = "*"
Expand All @@ -44,12 +42,12 @@ phonenumbers = "*"
deepmerge = "*"
prometheus-client = "*"
unidecode = "*"
httpx = ">=0.12.0"
httpx = ">=0.23.0"
geopy = "*"
py-mini-racer = "*"
geojson-pydantic = "*"
orjson = "*"
jellyfish = "*"

[requires]
python_version = "3.8"
python_version = "3.10"
Loading