Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/
FROM python:3.13-slim-bookworm
FROM python:3.13-slim-bookworm as builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Set our working directory
# Run uv in the builder
WORKDIR /usr/src/app

# Copy requirements.txt first for better cache on later pushes
COPY requirements.txt requirements.txt
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy

# pip install python deps from requirements.txt on the resin.io build server
RUN pip install -r requirements.txt
COPY uv.lock pyproject.toml ./

# This will copy all files in our root to the working directory in the container
RUN uv sync --locked --no-install-project

# Final image
FROM python:3.12-slim-bookworm

WORKDIR /usr/src/app

COPY --from=builder /usr/src/app/uv.lock uv.lock.builder

# Copy the required packages
COPY --from=builder /usr/src/app/.venv .venv/
ENV PYTHONPATH=/usr/src/app/.venv/lib/python3.13/site-packages

# Copy the app
COPY . ./

# main.py will run when container starts up on the device
CMD ["python","-u","src/app.py"]
CMD ["python","-u","src/app.py"]
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

[project]
name = "balena-python-hello-world"
version = "0.1.0"
description = "Sample Python project for Balena devices"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"click>=8.3.0",
"flask>=3.1.2",
"importlib-metadata>=8.7.0",
"itsdangerous>=2.2.0",
"jinja2>=3.1.6",
"markupsafe>=3.0.3",
"werkzeug>=3.1.3",
"zipp>=3.23.0",
]
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

Loading
Loading