### Install and Use Dockerpyze with Poetry Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This snippet demonstrates installing dockerpyze as a plugin for poetry, configuring the entrypoint in pyproject.toml, and then building the Docker image using the poetry command. ```bash poetry self add dockerpyze@latest ``` ```toml [tool.dpy] entrypoint = "poetry run " ``` ```bash poetry dockerpyze >No .dockerignore found, using a good default one 😉 >Building image: dockerpyze:latest 🔨 Successfully built images: ✅ (0.3s) - dockerpyze:latest ``` -------------------------------- ### Complete Dockerpyze Configuration Example Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This TOML snippet provides a comprehensive example of configuring various Dockerpyze options, including image name, packages, Python version, base image, tags, entrypoint, ports, environment variables, labels, apt packages, extra run instructions, and platform. ```toml [tool.dpy] name = "alternative-image-name" packages = ["myapp"] python = "3.12" base-image = "python:3.12-slim" tags = ["latest-dev"] entrypoint = ["python", "-m", "whatever"] ports = [5000] env = {"MY_APP_ENV" = "dev"} labels = {"MY_APP_LABEL" = "dev"} apt-packages = ["curl"] extra-run-instructions = ["RUN curl https://huggingface.co/transformers/"] platform = "linux/amd64" ``` -------------------------------- ### Install and Use Dockerpyze with uv Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This snippet shows how to install dockerpyze as a dev dependency for a uv project and configure the entrypoint in pyproject.toml. It then demonstrates the command to build the Docker image. ```bash uv add dockerpyze --dev ``` ```toml [tool.dpy] entrypoint = "uv run " ``` ```bash uv run dockerpyze >No .dockerignore found, using a good default one 😉 >Building image: dockerpyze:latest 🔨 Successfully built images: ✅ (0.3s) - dockerpyze:latest ``` -------------------------------- ### Docker Build Configuration Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md Configuration options for building Docker images with dockerpyze. This includes specifying apt packages for the build environment, extra build instructions, and arguments for the poetry install command. ```toml build-apt-packages = ["gcc"] extra-build-instructions = ["RUN poetry config http-basic.foo "] build-poetry-install-args = ["-E", "all", "--no-root"] ``` -------------------------------- ### Command Line Usage Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md Demonstrates how to access the command-line options for dockerpyze using either 'uv run' or 'poetry'. The --help flag provides detailed information on available commands and options. ```bash uv run dockerpyze --help poetry dockerpyze --help ``` -------------------------------- ### Configure Dockerpyze Entrypoint and Packages Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This TOML snippet shows how to configure the entrypoint and specify packages for the Docker image build process within the pyproject.toml file. ```toml [tool.dpy] packages = ["myapp"] entrypoint = ["python", "myapp/main.py"] ``` -------------------------------- ### GitHub Actions Workflow for Docker Image Build Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This YAML snippet outlines a GitHub Actions workflow to check out code, set up Python and uv, build and package the application using dockerpyze, log in to Docker Hub, and push the image. ```yaml name: Build and publish latest on: push: branches: main jobs: login: runs-on: ubuntu-latest steps: - name: Check out the repo uses: actions/checkout@v3 - name: "Setup: Python 3.11" uses: actions/setup-python@v4 - name: Install uv run: python -m pip install uv - name: Build and package run: | uv sync uv run ruff uv run pytest uv run dockerpyze - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push to Docker Hub run: docker push my-app:latest ``` -------------------------------- ### Configure Dockerpyze via Environment Variables Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This section explains how to configure Dockerpyze using environment variables, including setting the entrypoint and handling dictionary-like configurations for 'env' and 'labels'. ```bash export DPY_ENTRYPOINT="python -m myapp" uv run dockerpyze ``` ```bash echo "DPY_ENTRYPOINT=python -m myapp" > .env poetry dockerpyze ``` ```bash export DPY_ENV_MY_VAR="my_value" export DPY_ENV_MY_OTHER_VAR="my_other_value" export DPY_LABELS_MY_LABEL="label1" poetry dockerpyze ``` -------------------------------- ### dockerpyze Configuration Options Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md Defines various configuration parameters for dockerpyze to customize Docker image creation. These include image naming, package declarations, Python version, base image, tags, entrypoint, ports, environment variables, labels, apt packages, and run instructions. ```toml # name: customizes the docker image name. # 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. # python: python version to use. If not specified, will try to be extracted from tool.poetry.dependencies.python. Default is 3.11 # base-image: customizes the base image. If not defined, the default base image is python:-slim-bookworm. # tags: declares a list of tags for the image. # entrypoint: customizes the entrypoint of the image. If not provided, the default entrypoint is retrieved from the packages configuration. # ports: exposes ports # env: declares environment variables inside the docker image. # labels: append labels to the docker image. Default labels are added following the opencontainers specification. # apt-packages: installs apt packages inside the docker image. # 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. # 'platform': forces docker platform to be used. ``` -------------------------------- ### Generating Dockerfile for Manual Build Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md Provides commands to generate a Dockerfile using dockerpyze and then manually build the Docker image. This is useful for debugging when the automated build process fails. ```bash uv run dockerpyze --generate docker build Dockerfile . ``` -------------------------------- ### Debugging dockerpyze Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md Instructions on how to enable debug mode for troubleshooting dockerpyze. The --debug flag provides more verbose output during execution, which can help identify issues. ```bash poetry dockerpyze --debug ``` -------------------------------- ### Configure Dockerpyze Image Name Source: https://github.com/nicoloboschi/dockerpyze/blob/main/README.md This TOML snippet illustrates how to customize the name of the generated Docker image by setting the 'name' option in the pyproject.toml file. ```toml [tool.dpy] name = "myself/myproject-app" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.