From 4767ec3568fd2767e9c4d61dd8fc328ab7fd701e Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Fri, 6 May 2022 10:26:09 +0300 Subject: [PATCH] Update image building --- docker/production.dockerfile | 25 +++--------- poetry.lock | 78 ++++++++++++++++++++++-------------- pyproject.toml | 4 +- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/docker/production.dockerfile b/docker/production.dockerfile index 1f527e4..c69e611 100644 --- a/docker/production.dockerfile +++ b/docker/production.dockerfile @@ -1,38 +1,25 @@ -FROM python:3.10-slim as build-image - -RUN apt-get update \ - && apt-get install --no-install-recommends -y gcc build-essential python3-dev libpq-dev libffi-dev \ - && rm -rf /var/lib/apt/lists/* +FROM ghcr.io/kurbezz/base_docker_images:3.10-postgres-asyncpg-poetry-buildtime as build-image WORKDIR /root/poetry COPY pyproject.toml poetry.lock /root/poetry/ -RUN pip install poetry wheel --no-cache-dir \ - && poetry export --without-hashes > requirements.txt - ENV VENV_PATH=/opt/venv -RUN python -m venv $VENV_PATH \ +RUN poetry export --without-hashes > requirements.txt \ && . /opt/venv/bin/activate \ && pip install -r requirements.txt --no-cache-dir -FROM python:3.10-slim as runtime-image - -RUN apt-get update \ - && apt-get install --no-install-recommends -y python3-dev libpq-dev libffi-dev \ - && rm -rf /var/lib/apt/lists/* +FROM ghcr.io/kurbezz/base_docker_images:3.10-postgres-runtime as runtime-image WORKDIR /app -COPY ./fastapi_file_server/ /app/ - ENV VENV_PATH=/opt/venv -COPY --from=build-image $VENV_PATH $VENV_PATH ENV PATH="$VENV_PATH/bin:$PATH" -COPY ./scripts/start_production.sh /root/ -COPY ./scripts/healthcheck.py /root/healthcheck.py +COPY --from=build-image $VENV_PATH $VENV_PATH +COPY ./fastapi_file_server/ /app/ +COPY ./scripts/* /root/ EXPOSE 8080 diff --git a/poetry.lock b/poetry.lock index 4bcd054..45483fa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -54,7 +54,7 @@ tests = ["pytest", "pytest-asyncio", "mypy (>=0.800)"] [[package]] name = "asyncpg" -version = "0.24.0" +version = "0.25.0" description = "An asyncio PostgreSQL driver" category = "main" optional = false @@ -150,7 +150,7 @@ pycparser = "*" [[package]] name = "databases" -version = "0.5.3" +version = "0.5.5" description = "Async database support for Python." category = "main" optional = false @@ -161,6 +161,7 @@ sqlalchemy = ">=1.4,<1.5" [package.extras] mysql = ["aiomysql"] +mysql_asyncmy = ["asyncmy"] postgresql = ["asyncpg"] postgresql_aiopg = ["aiopg"] sqlite = ["aiosqlite"] @@ -329,25 +330,27 @@ python-versions = ">=3.7" [[package]] name = "ormar" -version = "0.10.22" +version = "0.11.0" description = "A simple async ORM with fastapi in mind and pydantic validation." category = "main" optional = false -python-versions = ">=3.6.2,<4.0.0" +python-versions = ">=3.7.0,<4.0.0" [package.dependencies] aiosqlite = ">=0.17.0,<0.18.0" -databases = ">=0.3.2,<0.5.4" -pydantic = ">=1.6.1,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<=1.8.2" -SQLAlchemy = ">=1.3.18,<1.4.26" +asyncpg = {version = ">=0.24,<0.26", optional = true, markers = "extra == \"postgresql\" or extra == \"postgres\" or extra == \"dev\""} +databases = ">=0.3.2,<0.5.0 || >0.5.0,<0.5.1 || >0.5.1,<0.5.2 || >0.5.2,<0.5.3 || >0.5.3,<=0.5.5" +psycopg2-binary = {version = ">=2.9.1,<3.0.0", optional = true, markers = "extra == \"postgresql\" or extra == \"postgres\" or extra == \"dev\""} +pydantic = ">=1.6.1,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<=1.9.1" +SQLAlchemy = ">=1.3.18,<=1.4.31" [package.extras] -postgresql = ["asyncpg (>=0.24.0,<0.25.0)", "psycopg2-binary (>=2.9.1,<3.0.0)"] -postgres = ["asyncpg (>=0.24.0,<0.25.0)", "psycopg2-binary (>=2.9.1,<3.0.0)"] -dev = ["asyncpg (>=0.24.0,<0.25.0)", "psycopg2-binary (>=2.9.1,<3.0.0)", "aiomysql (>=0.0.21,<0.0.22)", "cryptography (>=35.0.0,<36.0.0)", "orjson (>=3.6.4,<4.0.0)"] -mysql = ["aiomysql (>=0.0.21,<0.0.22)"] -crypto = ["cryptography (>=35.0.0,<36.0.0)"] -orjson = ["orjson (>=3.6.4,<4.0.0)"] +postgresql = ["asyncpg (>=0.24,<0.26)", "psycopg2-binary (>=2.9.1,<3.0.0)"] +postgres = ["asyncpg (>=0.24,<0.26)", "psycopg2-binary (>=2.9.1,<3.0.0)"] +dev = ["asyncpg (>=0.24,<0.26)", "psycopg2-binary (>=2.9.1,<3.0.0)", "aiomysql (>=0.0.21,<0.0.23)", "cryptography (>=35,<37)", "orjson (>=3.6.4)"] +mysql = ["aiomysql (>=0.0.21,<0.0.23)"] +crypto = ["cryptography (>=35,<37)"] +orjson = ["orjson (>=3.6.4)"] [[package]] name = "packaging" @@ -706,7 +709,7 @@ python-versions = "*" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "12cb73b598a9196c99c032c1eefaacfcc591468e5d4ae38fb39a3d902ffab5ae" +content-hash = "d6107bce93d698cbc96a96d0833934ae63f3ee6a6723cfbe369fa68743b89066" [metadata.files] aiosqlite = [ @@ -726,19 +729,32 @@ asgiref = [ {file = "asgiref-3.4.1.tar.gz", hash = "sha256:4ef1ab46b484e3c706329cedeff284a5d40824200638503f5768edb6de7d58e9"}, ] asyncpg = [ - {file = "asyncpg-0.24.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c4fc0205fe4ddd5aeb3dfdc0f7bafd43411181e1f5650189608e5971cceacff1"}, - {file = "asyncpg-0.24.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a7095890c96ba36f9f668eb552bb020dddb44f8e73e932f8573efc613ee83843"}, - {file = "asyncpg-0.24.0-cp310-cp310-win_amd64.whl", hash = "sha256:8ff5073d4b654e34bd5eaadc01dc4d68b8a9609084d835acd364cd934190a08d"}, - {file = "asyncpg-0.24.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e36c6806883786b19551bb70a4882561f31135dc8105a59662e0376cf5b2cbc5"}, - {file = "asyncpg-0.24.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ddffcb85227bf39cd1bedd4603e0082b243cf3b14ced64dce506a15b05232b83"}, - {file = "asyncpg-0.24.0-cp37-cp37m-win_amd64.whl", hash = "sha256:41704c561d354bef01353835a7846e5606faabbeb846214dfcf666cf53319f18"}, - {file = "asyncpg-0.24.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:29ef6ae0a617fc13cc2ac5dc8e9b367bb83cba220614b437af9b67766f4b6b20"}, - {file = "asyncpg-0.24.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:eed43abc6ccf1dc02e0d0efc06ce46a411362f3358847c6b0ec9a43426f91ece"}, - {file = "asyncpg-0.24.0-cp38-cp38-win_amd64.whl", hash = "sha256:129d501f3d30616afd51eb8d3142ef51ba05374256bd5834cec3ef4956a9b317"}, - {file = "asyncpg-0.24.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a458fc69051fbb67d995fdda46d75a012b5d6200f91e17d23d4751482640ed4c"}, - {file = "asyncpg-0.24.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:556b0e92e2b75dc028b3c4bc9bd5162ddf0053b856437cf1f04c97f9c6837d03"}, - {file = "asyncpg-0.24.0-cp39-cp39-win_amd64.whl", hash = "sha256:a738f4807c853623d3f93f0fea11f61be6b0e5ca16ea8aeb42c2c7ee742aa853"}, - {file = "asyncpg-0.24.0.tar.gz", hash = "sha256:dd2fa063c3344823487d9ddccb40802f02622ddf8bf8a6cc53885ee7a2c1c0c6"}, + {file = "asyncpg-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bf5e3408a14a17d480f36ebaf0401a12ff6ae5457fdf45e4e2775c51cc9517d3"}, + {file = "asyncpg-0.25.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2bc197fc4aca2fd24f60241057998124012469d2e414aed3f992579db0c88e3a"}, + {file = "asyncpg-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1a70783f6ffa34cc7dd2de20a873181414a34fd35a4a208a1f1a7f9f695e4ec4"}, + {file = "asyncpg-0.25.0-cp310-cp310-win32.whl", hash = "sha256:43cde84e996a3afe75f325a68300093425c2f47d340c0fc8912765cf24a1c095"}, + {file = "asyncpg-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:56d88d7ef4341412cd9c68efba323a4519c916979ba91b95d4c08799d2ff0c09"}, + {file = "asyncpg-0.25.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a84d30e6f850bac0876990bcd207362778e2208df0bee8be8da9f1558255e634"}, + {file = "asyncpg-0.25.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:beaecc52ad39614f6ca2e48c3ca15d56e24a2c15cbfdcb764a4320cc45f02fd5"}, + {file = "asyncpg-0.25.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:6f8f5fc975246eda83da8031a14004b9197f510c41511018e7b1bedde6968e92"}, + {file = "asyncpg-0.25.0-cp36-cp36m-win32.whl", hash = "sha256:ddb4c3263a8d63dcde3d2c4ac1c25206bfeb31fa83bd70fd539e10f87739dee4"}, + {file = "asyncpg-0.25.0-cp36-cp36m-win_amd64.whl", hash = "sha256:bf6dc9b55b9113f39eaa2057337ce3f9ef7de99a053b8a16360395ce588925cd"}, + {file = "asyncpg-0.25.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:acb311722352152936e58a8ee3c5b8e791b24e84cd7d777c414ff05b3530ca68"}, + {file = "asyncpg-0.25.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0a61fb196ce4dae2f2fa26eb20a778db21bbee484d2e798cb3cc988de13bdd1b"}, + {file = "asyncpg-0.25.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2633331cbc8429030b4f20f712f8d0fbba57fa8555ee9b2f45f981b81328b256"}, + {file = "asyncpg-0.25.0-cp37-cp37m-win32.whl", hash = "sha256:863d36eba4a7caa853fd7d83fad5fd5306f050cc2fe6e54fbe10cdb30420e5e9"}, + {file = "asyncpg-0.25.0-cp37-cp37m-win_amd64.whl", hash = "sha256:fe471ccd915b739ca65e2e4dbd92a11b44a5b37f2e38f70827a1c147dafe0fa8"}, + {file = "asyncpg-0.25.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:72a1e12ea0cf7c1e02794b697e3ca967b2360eaa2ce5d4bfdd8604ec2d6b774b"}, + {file = "asyncpg-0.25.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4327f691b1bdb222df27841938b3e04c14068166b3a97491bec2cb982f49f03e"}, + {file = "asyncpg-0.25.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:739bbd7f89a2b2f6bc44cb8bf967dab12c5bc714fcbe96e68d512be45ecdf962"}, + {file = "asyncpg-0.25.0-cp38-cp38-win32.whl", hash = "sha256:18d49e2d93a7139a2fdbd113e320cc47075049997268a61bfbe0dde680c55471"}, + {file = "asyncpg-0.25.0-cp38-cp38-win_amd64.whl", hash = "sha256:191fe6341385b7fdea7dbdcf47fd6db3fd198827dcc1f2b228476d13c05a03c6"}, + {file = "asyncpg-0.25.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:52fab7f1b2c29e187dd8781fce896249500cf055b63471ad66332e537e9b5f7e"}, + {file = "asyncpg-0.25.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a738f1b2876f30d710d3dc1e7858160a0afe1603ba16bf5f391f5316eb0ed855"}, + {file = "asyncpg-0.25.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5e4105f57ad1e8fbc8b1e535d8fcefa6ce6c71081228f08680c6dea24384ff0e"}, + {file = "asyncpg-0.25.0-cp39-cp39-win32.whl", hash = "sha256:f55918ded7b85723a5eaeb34e86e7b9280d4474be67df853ab5a7fa0cc7c6bf2"}, + {file = "asyncpg-0.25.0-cp39-cp39-win_amd64.whl", hash = "sha256:649e2966d98cc48d0646d9a4e29abecd8b59d38d55c256d5c857f6b27b7407ac"}, + {file = "asyncpg-0.25.0.tar.gz", hash = "sha256:63f8e6a69733b285497c2855464a34de657f2cccd25aeaeeb5071872e9382540"}, ] atomicwrites = [ {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, @@ -853,8 +869,8 @@ cryptg = [ {file = "cryptg-0.2.post4.tar.gz", hash = "sha256:a4de1730ca56aa8a945f176c25586901ed5e9f15ffb70c6459eedf466eb6299b"}, ] databases = [ - {file = "databases-0.5.3-py3-none-any.whl", hash = "sha256:23862bd96241d8fcbf97eea82995ccb3baa8415c3cb106832b7509f296322f86"}, - {file = "databases-0.5.3.tar.gz", hash = "sha256:b69d74ee0b47fa30bb6e76db0c58da998e973393259d29215d8fb29352162bd6"}, + {file = "databases-0.5.5-py3-none-any.whl", hash = "sha256:97d9b9647216d1ab53ca61c059412b5c7b6e1f0bf8ce985477982ebcc7f278f3"}, + {file = "databases-0.5.5.tar.gz", hash = "sha256:02c6b016c1c951c21cca281dc8e2e002c60dc44026c0084aabbd8c37514aeb37"}, ] fastapi = [ {file = "fastapi-0.75.1-py3-none-any.whl", hash = "sha256:f46f8fc81261c2bd956584114da9da98c84e2410c807bc2487532dabf55e7ab8"}, @@ -1080,8 +1096,8 @@ orjson = [ {file = "orjson-3.6.7.tar.gz", hash = "sha256:a4bb62b11289b7620eead2f25695212e9ac77fcfba76f050fa8a540fb5c32401"}, ] ormar = [ - {file = "ormar-0.10.22-py3-none-any.whl", hash = "sha256:d38d53dc191442902c541db06a1c260f5a3820d1690cbcd79a3b6edca37b4653"}, - {file = "ormar-0.10.22.tar.gz", hash = "sha256:6235f2898c818350970ea3b60ddda41d92c75308be60520a6e5466dbb9ceafe3"}, + {file = "ormar-0.11.0-py3-none-any.whl", hash = "sha256:5082ae37fa05f40e1ccaf1b082e6075f82eafd9fa1a90d57b2446719c7390dd1"}, + {file = "ormar-0.11.0.tar.gz", hash = "sha256:8703e545dfd61449fc5fd55aaa82f2185841b85eeb1ed7bde41c723d996d2dfb"}, ] packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, diff --git a/pyproject.toml b/pyproject.toml index 95ab205..5e7cc76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,16 +9,14 @@ license = "Apache 2.0" python = "^3.9" fastapi = ">=0.71.0" uvicorn = {extras = ["standart"], version = "^0.15.0"} -ormar = "^0.10.19" +ormar = {extras = ["postgresql"], version = "^0.11.0"} alembic = "^1.7.3" pydantic = {extras = ["dotenv"], version = "^1.8.2"} -asyncpg = "^0.24.0" python-multipart = "^0.0.5" httpx = "^0.22.0" Telethon = "^1.24.0" cryptg = "^0.2.post4" prometheus-fastapi-instrumentator = "^5.7.1" -psycopg2-binary = "^2.9.3" uvloop = "^0.16.0" gunicorn = "^20.1.0" orjson = "^3.6.7"