Skip to content

Conversation

@toro-berlin
Copy link
Contributor

@toro-berlin toro-berlin commented Apr 2, 2025

What I'm changing

  • Adds a .dockerignore that defines the files that get moved into the docker image.
  • Adds a Dockerfile that installs the Python package based on the uv lock file and executes the FastAPI application.
  • Adds a GitHub job executed on pushed tags that builds the image and pushes them to the GitHub registry.

closes #48

How I did it

  • We put the GitHub job into the release workflow, as it should only be executed on release.
  • Therefore, we renamed the existing jobs to associate them with the pypi release process.

Checklist

  • Tests pass: uv run pytest
  • Checks pass: uv run pre-commit --all-files
  • CHANGELOG is updated (if necessary)

@toro-berlin toro-berlin marked this pull request as ready for review April 2, 2025 10:58
@toro-berlin toro-berlin requested a review from gadomski as a code owner April 2, 2025 10:58
toro-berlin and others added 4 commits April 2, 2025 13:38
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
@toro-berlin toro-berlin requested a review from gadomski April 2, 2025 11:51
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this error when building locally:

 => ERROR [4/4] RUN uv sync --frozen                                                                                                                                                                      0.3s
------                                                                                                                                                                                                         
 > [4/4] RUN uv sync --frozen:
0.289 Using CPython 3.12.9 interpreter at: /usr/local/bin/python3
0.289 Creating virtual environment at: .venv
0.301 error: Failed to determine installation plan
0.301   Caused by: Distribution not found at: file:///app/pystapi-validator
------

 1 warning found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 4)
Dockerfile:9
--------------------
   7 |     COPY . /app
   8 |     
   9 | >>> RUN uv sync --frozen
  10 |     
  11 |     CMD ["uv", "run", "fastapi", "dev", "/app/stapi-fastapi/tests/application.py", "--host", "0.0.0.0", "--port", "80"]
--------------------
ERROR: failed to solve: process "/bin/sh -c uv sync --frozen" did not complete successfully: exit code: 2

I think it would make sense to build the dockerfile (but not push it) in ci.yaml as well, to ensure it builds ok?

toro-berlin and others added 3 commits April 2, 2025 15:39
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
@toro-berlin toro-berlin requested a review from gadomski April 2, 2025 14:08
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still getting this error when building locally:

 => ERROR [4/4] RUN uv sync --frozen                                                                                                                                           0.3s
------                                                                                                                                                                              
 > [4/4] RUN uv sync --frozen:
0.270 Using CPython 3.12.9 interpreter at: /usr/local/bin/python3
0.270 Creating virtual environment at: .venv
0.279 error: Failed to determine installation plan
0.279   Caused by: Distribution not found at: file:///app/pystapi-validator
------
Dockerfile:9
--------------------
   7 |     COPY . /app
   8 |     
   9 | >>> RUN uv sync --frozen
  10 |     
  11 |     CMD ["uv", "run", "fastapi", "dev", "/app/stapi-fastapi/tests/application.py", "--host", "0.0.0.0", "--port", "80"]
--------------------
ERROR: failed to solve: process "/bin/sh -c uv sync --frozen" did not complete successfully: exit code: 2

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/ogrcl2mcd2tj2mk5gua86tsyt

@toro-berlin toro-berlin requested a review from gadomski April 2, 2025 14:45
@toro-berlin
Copy link
Contributor Author

Should work now @gadomski

@gadomski gadomski changed the title feat: Add fastapi docker feat: add fastapi docker Apr 3, 2025
@gadomski gadomski merged commit 057aa5a into stapi-spec:main Apr 3, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create docker image for stapi-fastapi

3 participants