-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deployment): Add Docker and Fly.io integration
* Add a .dockerignore file to exclude unnecessary files and directories (like .git, __pycache__, .envrc, .venv, and fly.toml) from Docker builds, optimizing build context size and performance. * Introduce a Dockerfile setting up a multi-stage build for the `pucoti` application using Python 3.12. This enhances container performance by separating dependencies installation and the runtime environment. * Set up a GitHub Actions workflow `fly-deploy.yml` for continuous deployment to Fly.io. It triggers on pushes to the main branch and deploys the app using `flyctl`. * Create a fly.toml file for configuring Fly.io deployments, including app settings such as region, HTTP service preferences, vm size, and processes.
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fly.toml | ||
.git/ | ||
__pycache__/ | ||
.envrc | ||
.venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.12 AS builder | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
WORKDIR /app | ||
|
||
RUN pip install poetry | ||
RUN poetry config virtualenvs.in-project true | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry install | ||
FROM python:3.12-slim | ||
WORKDIR /app | ||
COPY --from=builder /app/.venv .venv/ | ||
COPY . . | ||
CMD ["/app/.venv/bin/uvicorn", "pucoti.server:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# fly.toml app configuration file generated for pucoti on 2024-09-21T19:52:26+02:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'pucoti' | ||
primary_region = 'cdg' | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 8000 | ||
force_https = true | ||
auto_stop_machines = 'stop' | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
max_machines_running = 1 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
size = 'shared-cpu-1x' |