Skip to content

Commit

Permalink
Swap out pipenv for rye
Browse files Browse the repository at this point in the history
  • Loading branch information
dmannarino committed Dec 29, 2023
1 parent 85ee547 commit 984df2b
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 24 deletions.
48 changes: 25 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,41 @@ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim
# Optional build argument for different environments
ARG ENV

ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"

RUN apt-get update -y \
&& apt-get install --no-install-recommends -y gcc libc-dev musl-dev \
postgresql-client libpq-dev make git jq \
&& apt-get install --no-install-recommends -y gcc clang libc-dev musl-dev \
postgresql-client libpq-dev make git jq curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSf https://rye-up.com/get | RYE_NO_AUTO_INSTALL=1 RYE_TOOLCHAIN=/usr/bin/python RYE_INSTALL_OPTION="--yes" bash

COPY ./app /app/app
WORKDIR /app

RUN pip install --upgrade pip && pip install pipenv==v2022.11.30
#TODO move to pipfile when operational
RUN pip install newrelic
COPY alembic.ini /app/alembic.ini
COPY newrelic.ini /app/newrelic.ini
COPY app/settings/prestart.sh /app/prestart.sh
COPY app/settings/start.sh /app/start.sh
COPY wait_for_postgres.sh /usr/local/bin/wait_for_postgres.sh

RUN chmod +x /usr/local/bin/wait_for_postgres.sh
RUN chmod +x /app/start.sh

# Install python dependencies
# Install everything for dev and test otherwise just core dependencies
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
COPY .python-version /app/.python-version
COPY pyproject.toml /app/pyproject.toml
COPY README.md /app/README.md
COPY requirements-dev.lock /app/requirements-dev.lock
COPY requirements.lock /app/requirements.lock

RUN if [ "$ENV" = "dev" ] || [ "$ENV" = "test" ]; then \
echo "Install all dependencies" \
&& pipenv install --system --deploy --ignore-pipfile --dev; \
&& RYE_TOOLCHAIN=/usr/bin/python rye sync --no-lock; \
else \
echo "Install production dependencies only" \
&& pipenv install --system --deploy; \
&& RYE_TOOLCHAIN=/usr/bin/python rye sync --no-dev --no-lock; \
fi

COPY ./app /app/app

COPY alembic.ini /app/alembic.ini

COPY app/settings/prestart.sh /app/prestart.sh
COPY app/settings/start.sh /app/start.sh
COPY newrelic.ini /app/newrelic.ini

COPY wait_for_postgres.sh /usr/local/bin/wait_for_postgres.sh
RUN chmod +x /usr/local/bin/wait_for_postgres.sh
RUN chmod +x /app/start.sh

ENTRYPOINT [ "/app/start.sh" ]
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ services:
- API_GATEWAY_STAGE_NAME=test
# - AWS_GCS_KEY_SECRET_ARN=testing
# - AWS_SECRETSMANAGER_URL=http://motoserver-secretsmanager:5001
entrypoint: wait_for_postgres.sh pytest --timeout 480 -vv --cov-report term --cov=app
entrypoint: wait_for_postgres.sh rye run pytest --timeout 480 -vv --cov-report term --cov=app
depends_on:
- test_database_12
- motoserver-s3
Expand Down
73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[project]
name = "gfw-data-api"
version = "0.1.0"
description = "Add your description here"
authors = [
]
dependencies = [
"aenum>=3.1.15",
"aiofiles>=23.2.1",
"aiohttp>=3.9.1",
"alembic>=1.13.1",
"arq>=0.25.0",
"async-lru>=2.0.4",
"boto3>=1.34.9",
"botocore>=1.34.9",
"email-validator>=2.1.0.post1",
"geojson>=3.1.0",
"gino>=1.0.1",
"gino_starlette==0.1.2",
"geoalchemy2<0.12",
"google-cloud-storage>=2.14.0",
"httpcore>=1.0.2",
"httpx>=0.25.1",
"httpx-auth>=0.18.0",
"numpy>=1.26.2",
"orjson>=3.9.10",
"packaging>=23.2",
"pendulum>=3.0.0",
"pglast<2",
"psutil>=5.9.7",
"psycopg2>=2.9.9",
"pyproj>=3.6.1",
"python-multipart>=0.0.6",
"retrying>=1.3.4",
"shapely>=2.0.2",
"sqlalchemy<1.4",
"sqlalchemy-utils>=0.41.1",
"starlette<0.15",
"pydantic~=1.9",
"typer>=0.9.0",
"uvicorn[standard]>=0.25.0",
"fastapi<0.68",
"asyncpg>=0.29.0",
"newrelic>=9.3.0",
]
readme = "README.md"
requires-python = "~= 3.10"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
"pytest>=7.4.3",
"docker>=7.0.0",
"moto[awslambda, batch, ec2, s3]>=4.2.12",
"pytest-asyncio<0.19",
"pytest-timeout>=2.2.0",
"responses<0.16",
"rasterio>=1.3.9",
"pytest-cov>=4.1.0",
"gfw_pixetl @ git+https://github.com/wri/gfw_pixetl.git@develop",
"pandas>=2.1.4",
"openapi_spec_validator>=0.7.1",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["app", "batch"]
132 changes: 132 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false

-e file:.
aenum==3.1.15
affine==2.4.0
aiofiles==23.2.1
aiohttp==3.9.1
aiosignal==1.3.1
alembic==1.13.1
anyio==4.2.0
arq==0.25.0
async-lru==2.0.4
async-timeout==4.0.3
asyncpg==0.29.0
attrs==23.1.0
boto3==1.34.9
botocore==1.34.9
cachetools==5.3.2
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
coverage==7.4.0
cryptography==41.0.7
dnspython==2.4.2
docker==7.0.0
ecdsa==0.18.0
email-validator==2.1.0.post1
exceptiongroup==1.2.0
fastapi==0.67.0
frozenlist==1.4.1
geoalchemy2==0.11.1
geojson==3.1.0
gfw-pixetl @ git+https://github.com/wri/gfw_pixetl.git@develop
gino==1.0.1
gino-starlette==0.1.2
google-api-core==2.15.0
google-auth==2.25.2
google-cloud-core==2.4.1
google-cloud-storage==2.14.0
google-crc32c==1.5.0
google-resumable-media==2.7.0
googleapis-common-protos==1.62.0
h11==0.14.0
hiredis==2.3.2
httpcore==1.0.2
httptools==0.6.1
httpx==0.25.2
httpx-auth==0.18.0
idna==3.6
iniconfig==2.0.0
jinja2==3.1.2
jmespath==1.0.1
jsonschema==4.20.0
jsonschema-path==0.3.2
jsonschema-specifications==2023.12.1
lazy-object-proxy==1.10.0
mako==1.3.0
markupsafe==2.1.3
moto==4.2.12
multidict==6.0.4
newrelic==9.3.0
numpy==1.26.2
openapi-schema-validator==0.6.2
openapi-spec-validator==0.7.1
orjson==3.9.10
packaging==23.2
pandas==2.1.4
pathable==0.4.3
pendulum==3.0.0
pglast==1.18
pluggy==1.3.0
protobuf==4.25.1
psutil==5.9.7
psycopg2==2.9.9
py-partiql-parser==0.5.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
pydantic==1.10.13
pyparsing==3.1.1
pyproj==3.6.1
pytest==7.4.3
pytest-asyncio==0.18.3
pytest-cov==4.1.0
pytest-timeout==2.2.0
python-dateutil==2.8.2
python-dotenv==1.0.0
python-multipart==0.0.6
pytz==2023.3.post1
pyyaml==6.0.1
rasterio==1.3.9
redis==5.0.1
referencing==0.31.1
requests==2.31.0
responses==0.15.0
retrying==1.3.4
rfc3339-validator==0.1.4
rpds-py==0.15.2
rsa==4.9
s3transfer==0.10.0
shapely==2.0.2
six==1.16.0
sniffio==1.3.0
snuggs==1.4.7
sqlalchemy==1.3.24
sqlalchemy-utils==0.41.1
sshpubkeys==3.3.1
starlette==0.14.2
time-machine==2.13.0
tomli==2.0.1
typer==0.9.0
typing-extensions==4.9.0
tzdata==2023.3
urllib3==2.0.7
uvicorn==0.25.0
uvloop==0.19.0
watchfiles==0.21.0
websockets==12.0
werkzeug==3.0.1
xmltodict==0.13.0
yarl==1.9.4
# The following packages are considered to be unsafe in a requirements file:
setuptools==69.0.3
93 changes: 93 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false

-e file:.
aenum==3.1.15
aiofiles==23.2.1
aiohttp==3.9.1
aiosignal==1.3.1
alembic==1.13.1
anyio==4.2.0
arq==0.25.0
async-lru==2.0.4
async-timeout==4.0.3
asyncpg==0.29.0
attrs==23.1.0
boto3==1.34.9
botocore==1.34.9
cachetools==5.3.2
certifi==2023.11.17
charset-normalizer==3.3.2
click==8.1.7
dnspython==2.4.2
email-validator==2.1.0.post1
exceptiongroup==1.2.0
fastapi==0.67.0
frozenlist==1.4.1
geoalchemy2==0.11.1
geojson==3.1.0
gino==1.0.1
gino-starlette==0.1.2
google-api-core==2.15.0
google-auth==2.25.2
google-cloud-core==2.4.1
google-cloud-storage==2.14.0
google-crc32c==1.5.0
google-resumable-media==2.7.0
googleapis-common-protos==1.62.0
h11==0.14.0
hiredis==2.3.2
httpcore==1.0.2
httptools==0.6.1
httpx==0.25.2
httpx-auth==0.18.0
idna==3.6
jmespath==1.0.1
mako==1.3.0
markupsafe==2.1.3
multidict==6.0.4
newrelic==9.3.0
numpy==1.26.2
orjson==3.9.10
packaging==23.2
pendulum==3.0.0
pglast==1.18
protobuf==4.25.1
psutil==5.9.7
psycopg2==2.9.9
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==1.10.13
pyproj==3.6.1
python-dateutil==2.8.2
python-dotenv==1.0.0
python-multipart==0.0.6
pyyaml==6.0.1
redis==5.0.1
requests==2.31.0
retrying==1.3.4
rsa==4.9
s3transfer==0.10.0
shapely==2.0.2
six==1.16.0
sniffio==1.3.0
sqlalchemy==1.3.24
sqlalchemy-utils==0.41.1
starlette==0.14.2
time-machine==2.13.0
typer==0.9.0
typing-extensions==4.9.0
tzdata==2023.3
urllib3==2.0.7
uvicorn==0.25.0
uvloop==0.19.0
watchfiles==0.21.0
websockets==12.0
yarl==1.9.4
# The following packages are considered to be unsafe in a requirements file:
setuptools==69.0.3

0 comments on commit 984df2b

Please sign in to comment.