{"id":19190878,"url":"https://github.com/svx/poetry-fastapi-docker","last_synced_at":"2025-10-07T05:36:23.884Z","repository":{"id":37483944,"uuid":"368531122","full_name":"svx/poetry-fastapi-docker","owner":"svx","description":"Docker multi-stage builds for Python and Poetry","archived":false,"fork":false,"pushed_at":"2024-04-15T01:38:27.000Z","size":87,"stargazers_count":96,"open_issues_count":3,"forks_count":33,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T14:57:13.437Z","etag":null,"topics":["docker","fastapi","poetry","python"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/svx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-18T12:59:38.000Z","updated_at":"2025-03-14T03:34:32.000Z","dependencies_parsed_at":"2024-11-09T11:36:56.657Z","dependency_job_id":null,"html_url":"https://github.com/svx/poetry-fastapi-docker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svx%2Fpoetry-fastapi-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svx%2Fpoetry-fastapi-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svx%2Fpoetry-fastapi-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svx%2Fpoetry-fastapi-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svx","download_url":"https://codeload.github.com/svx/poetry-fastapi-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094937,"owners_count":21211836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","poetry","python"],"created_at":"2024-11-09T11:36:51.119Z","updated_at":"2025-10-07T05:36:18.855Z","avatar_url":"https://github.com/svx.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePoetry - FastAPI - Docker\u003c/h1\u003e\n\n\u003e **Note** I currently do not actively use or maintain this project, the versions of Debian, Python and Poetry are not up to date!\n\n## Table Of Contents\n\n- [About the Project](#about-the-project)\n- [Requirements](#requirements)\n- [Local development](#local-development)\n- [Docker](#docker)\n- [Credits](#credits)\n\n## About The Project\n\nThis repo serves as a minimal reference on setting up docker multi-stage builds with poetry.\n\nThis is an updated and modified fork of [python-poetry-docker-example](https://github.com/michael0liver/python-poetry-docker-example).\n\n\u003e **Note** - This is only tested with Linux and macOS\n\n### Differences\n\n- Newer poetry version\n- Install poetry from python-poetry GitHub source\n- Does not run production image as `/root`\n- Set the SHELL option `-o pipefail` before RUN with a pipe\n\n## Requirements\n\n- [Docker \u003e= 17.05](https://www.python.org/downloads/release/python-381/)\n- [Python \u003e= 3.7](https://www.python.org/downloads/release/python-381/)\n- [Poetry](https://github.com/python-poetry/poetry)\n\n\u003e **NOTE** - Run all commands from the project root\n\n## Local development\n\n### Poetry\n\nCreate the virtual environment and install dependencies with:\n\n```shell\npoetry install\n```\n\nSee the [poetry docs](https://python-poetry.org/docs/) for information on how to add/update dependencies.\n\nRun commands inside the virtual environment with:\n\n```shell\npoetry run \u003cyour_command\u003e\n```\n\nSpawn a shell inside the virtual environment with:\n\n```shell\npoetry shell\n```\n\nStart a development server locally:\n\n```shell\npoetry run uvicorn app.main:app --reload --host localhost --port 8000\n```\n\nAPI will be available at [localhost:8000/](http://localhost:8000/)\n\n- Swagger UI docs at [localhost:8000/docs](http://localhost:8000/docs)\n- ReDoc docs at [localhost:8000/redoc](http://localhost:8000/redoc)\n\nTo run testing/linting locally you would run lint/test in the [scripts directory](/scripts).\n\n## Docker\n\nBuild images with:\n\n```shell\ndocker build -t poetry-project .\n```\n\nThe Dockerfile uses multi-stage builds to run lint and test stages before building the production stage.\nIf linting or testing fails the build will fail.\n\nYou can stop the build at specific stages with the `--target` option:\n\n```shell\ndocker build -t poetry-project --target $STAGE .\n```\n\nFor example we wanted to stop at the **test** stage:\n\n```shell\ndocker build -t poetry-project --target test .\n```\n\nWe could then get a shell inside the container with:\n\n```shell\ndocker run -it poetry-project bash\n```\n\nIf you do not specify a target the resulting image will be the last image defined which in our case is the 'production' image.\n\nRun the 'production' image:\n\n```shell\ndocker run -it -p 8000:8000 poetry-project\n```\n\nOpen your browser and go to [http://localhost:8000/redoc](http://localhost:8000/redoc) to see the API spec in ReDoc.\n\n### Docker Compose\n\nYou can build and run the container with Docker Compose\n\n```shell\ndocker compose up\n```\n\nOr, run in *detached* mode if you prefer.\n\n\u003e **NOTE** - If you use an older version of Docker Compose,\n\u003e you may need to uncomment the version in the docker-compose,yml file!\n\n## Credits\n\n- [Michael Oliver](https://github.com/michael0liver/python-poetry-docker-example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvx%2Fpoetry-fastapi-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvx%2Fpoetry-fastapi-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvx%2Fpoetry-fastapi-docker/lists"}