{"id":26785582,"url":"https://github.com/nicoloboschi/dockerpyze","last_synced_at":"2025-04-07T15:08:00.083Z","repository":{"id":208482786,"uuid":"721672768","full_name":"nicoloboschi/dockerpyze","owner":"nicoloboschi","description":"Python applications to Docker, automatically.","archived":false,"fork":false,"pushed_at":"2025-04-04T13:04:15.000Z","size":956,"stargazers_count":115,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-04T13:32:34.419Z","etag":null,"topics":["docker","poetry","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/nicoloboschi.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":"2023-11-21T14:39:47.000Z","updated_at":"2025-04-04T12:55:45.000Z","dependencies_parsed_at":"2024-01-29T16:41:11.787Z","dependency_job_id":"d9512262-0ed9-4211-bc77-e41a719e7e42","html_url":"https://github.com/nicoloboschi/dockerpyze","commit_stats":null,"previous_names":["nicoloboschi/poetry-docker-plugin","nicoloboschi/poetry-dockerize-plugin","nicoloboschi/dockerpyze"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicoloboschi%2Fdockerpyze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicoloboschi%2Fdockerpyze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicoloboschi%2Fdockerpyze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicoloboschi%2Fdockerpyze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicoloboschi","download_url":"https://codeload.github.com/nicoloboschi/dockerpyze/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675597,"owners_count":20977376,"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","poetry","python"],"created_at":"2025-03-29T11:08:47.683Z","updated_at":"2025-04-07T15:08:00.069Z","avatar_url":"https://github.com/nicoloboschi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockerpyze (dpy)\n\n\u003e Previously named poetry-dockerize-plugin\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/nicoloboschi/dockerpyze/refs/heads/main/dockerpyze.webp\" alt=\"PyPI\"\u003e\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/dockerpyze/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/dockerpyze?color=green\u0026amp;label=pypi%20package\" alt=\"PyPI\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/project/poetry-dockerize-plugin\"\u003e\n    \u003cimg src=\"https://static.pepy.tech/badge/poetry-dockerize-plugin\" alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/dockerpyze?color=green\" alt=\"Py versions\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n**Key features**:\n\n* Automatically generate a docker image from your `uv`/`poetry` application.\n* PEP-621 compliant.\n* 100% configurable. You can configure the image by adding a section in the `pyproject.toml` configuration file.\n\n## Quickstart\n\n### uv\n1. Install it as a dev dependency:\n```\nuv add dockerpyze --dev\n```\n2. Configure entrypoint in `pyproject.toml`:\n```toml\n[tool.dpy]\nentrypoint = \"uv run \u003cyour-script\u003e\"\n```\n3. Now straight to the point:\n```bash\nuv run dockerpyze\n\u003eNo .dockerignore found, using a good default one 😉\n\u003eBuilding image: dockerpyze:latest 🔨\nSuccessfully built images: ✅  (0.3s)\n  - dockerpyze:latest\n```\n4. Tell your friends about this library 😉\n\n\n### poetry\n0. Move your project to `uv`... well if you can't do it, you can still use `poetry`.\n1. Install the freaking plugin:\n```\npoetry self add dockerpyze@latest\n```\n2. Configure entrypoint in `pyproject.toml`:\n```toml\n[tool.dpy]\nentrypoint = \"poetry run \u003cyour-script\u003e\"\n```\n3. Now straight to the point:\n```bash\npoetry dockerpyze\n\u003eNo .dockerignore found, using a good default one 😉\n\u003eBuilding image: dockerpyze:latest 🔨\nSuccessfully built images: ✅  (0.3s)\n  - dockerpyze:latest\n```\n4. Tell your friends about this library 😉 (and then switch to `uv`)\n\n\n## Configure entrypoint\nIt's recommended to configure the entrypoint for the docker image:\n```toml\n[tool.dpy]\npackages = [\"myapp\"]\nentrypoint = [\"python\", \"myapp/main.py\"]\n```\n\n## Configuration via pyproject.toml\nTo customize some options, you can add a `[tool.dpy]` section in your `pyproject.toml` file. For example to change the image name:\n\n```toml\n[tool.dpy]\nname = \"myself/myproject-app\"\n```\n\n## Configuration via environment variables\nYou can also pass any option via environment variable by prefixing the key with `DPY_`. For example, to set the `entrypoint` you can use the `DPY_ENTRYPOINT` environment variable:\n\n```bash\nexport DPY_ENTRYPOINT=\"python -m myapp\"\nuv run dockerpyze\n```\n\nor use a .env file which will be loaded by the plugin:\n```\necho \"DPY_ENTRYPOINT=python -m myapp\" \u003e .env\npoetry dockerpyze\n```\n\nFor dicts such as `env` and `labels`, you can set multiple values by adding multiple variables:\n\n```bash\nexport DPY_ENV_MY_VAR=\"my_value\"\nexport DPY_ENV_MY_OTHER_VAR=\"my_other_value\"\nexport DPY_LABELS_MY_LABEL=\"label1\"\npoetry dockerpyze\n```\n\n## Usage in GitHub Actions\nYou just need to run the quickstart command in your GitHub Actions workflow:\n```yaml\n\nname: Build and publish latest\n\non:\n  push:\n    branches: main\n\njobs:\n  login:\n    runs-on: ubuntu-latest\n    steps:\n        - name: Check out the repo\n          uses: actions/checkout@v3\n\n        - name: \"Setup: Python 3.11\"\n          uses: actions/setup-python@v4\n\n        - name: Install uv\n          run: python -m pip install uv\n\n        - name: Build and package\n          run: |\n            uv sync\n            uv run ruff \n            uv run pytest\n            uv run dockerpyze\n\n        - name: Login to Docker Hub\n          uses: docker/login-action@v3\n          with:\n            username: ${{ secrets.DOCKERHUB_USERNAME }}\n            password: ${{ secrets.DOCKERHUB_TOKEN }}\n\n        - name: Push to Docker Hub\n          run: docker push my-app:latest\n```\n\n\n\n## Configuration API Reference\n\nThis examples shows a complete configuration of the docker image:\n\n```toml\n[tool.dpy]\nname = \"alternative-image-name\"\npackages = [\"myapp\"]\npython = \"3.12\"\nbase-image = \"python:3.12-slim\"\ntags = [\"latest-dev\"]\nentrypoint = [\"python\", \"-m\", \"whatever\"]\nports = [5000]\nenv = {\"MY_APP_ENV\" = \"dev\"}\nlabels = {\"MY_APP_LABEL\" = \"dev\"}\napt-packages = [\"curl\"]\nextra-run-instructions = [\"RUN curl https://huggingface.co/transformers/\"]\nplatform = \"linux/amd64\"\n\n# Only for build docker layer\nbuild-apt-packages = [\"gcc\"]\nextra-build-instructions = [\"RUN poetry config http-basic.foo \u003cusername\u003e \u003cpassword\u003e\"]\nbuild-poetry-install-args = [\"-E\", \"all\", \"--no-root\"]\n\n```\n\n* `name` customizes the docker image name. \n* `packages` declares the packages to be included in the docker image. If you they are declared in `[project.scripts]` or in `[tool.poetry.scripts]`, they will be automatically added to the list.\n* `python` python version to use. If not specified, will try to be extracted from `tool.poetry.dependencies.python`. Default is `3.11`\n* `base-image` customizes the base image. If not defined, the default base image is `python:\u003cpython-version\u003e-slim-bookworm`. \n* `tags` declares a list of tags for the image.\n* `entrypoint` customizes the entrypoint of the image. If not provided, the default entrypoint is retrieved from the `packages` configuration.\n* `ports` exposes ports\n* `env` declares environment variables inside the docker image.\n* `labels` append labels to the docker image. Default labels are added following the opencontainers specification.\n* `apt-packages` installs apt packages inside the docker image.\n* `extra-run-instructions` adds extra instructions to the docker run (after poetry install). Any modification to the filesystem will be kept after the poetry install.\n* 'platform' forces docker platform to be used. \n\nFor the build step:\n* `build-apt-packages` installs apt packages inside the build docker container.\n* `extra-build-instructions` adds extra instructions to the docker build (before poetry install). Any modification to the filesystem will be lost after the poetry install. If you need to add files to the image, use the `extra-run-instructions`.\n* `build-poetry-install-args` adds additional arguments to the `poetry install` command in the build step.\n\n\n## Command line options\n\nAll command line options provided by the `dockerpyze` may be accessed by typing:\n\n```bash\nuv run dockerpyze --help\npoetry dockerpyze --help\n```\n\n## Troubleshooting\n\nTo troubleshoot the plugin, you can use the `--debug` flag to get more information about the execution.\n\n```bash\npoetry dockerpyze --debug\n```\n\nThe build is broken and `--debug` is completely useless? I get it. \nYou can generate the `Dockerfile` and manually build it to have more control over the problem.\n```\nuv run dockerpyze --generate\ndocker build Dockerfile .\n```\n\n\u003eIt's totally fine to use the `--generate` flag to generate the initial `Dockerfile` and then customize it. I don't mind.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n## Issues or want to contribute?\n1. Open an issue \n2. (optional) Open a pull request and I'll merge it, maybe.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicoloboschi%2Fdockerpyze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicoloboschi%2Fdockerpyze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicoloboschi%2Fdockerpyze/lists"}