Skip to content

Commit c31d842

Browse files
committed
deployment
1 parent d705037 commit c31d842

7 files changed

Lines changed: 65 additions & 1 deletion

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fly.toml

.github/workflows/fly.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Staging Fly Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
deploy:
8+
name: Deploy to fly.io
9+
runs-on: ubuntu-latest
10+
environment: main
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
- uses: superfly/flyctl-actions/setup-flyctl@master
15+
- run: flyctl deploy --remote-only
16+
env:
17+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use a lightweight Python base image
2+
FROM python:3.11-slim
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy requirement files first (better caching)
8+
COPY requirements.txt requirements.txt
9+
10+
# Install dependencies
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# Copy app files
14+
COPY . .
15+
16+
# Expose the port (Fly will map this automatically)
17+
EXPOSE 8080
18+
19+
# Run with Gunicorn
20+
CMD ["gunicorn", "-b", "0.0.0.0:8080", "app:app"]

Procfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Modify this Procfile to fit your needs
2+
web: gunicorn server:app

app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import math
23

34
from flask import Flask, request, jsonify
@@ -125,4 +126,5 @@ def generate_cadastral_plan():
125126
return jsonify({"message": "Cadastral plan generated", "filename": plan.name}), 200
126127

127128
if __name__ == '__main__':
128-
app.run(host="0.0.0.0", port=8080, debug=True)
129+
port = int(os.environ.get("PORT", 8080))
130+
app.run(host="0.0.0.0", port=port)

fly.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# fly.toml app configuration file generated for fyp-python on 2025-09-16T13:12:30+01:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = "fyp-python"
7+
primary_region = "ams"
8+
9+
[build]
10+
builder = "paketobuildpacks/builder:base"
11+
12+
[env]
13+
PORT = "8080"
14+
15+
[http_service]
16+
internal_port = 8080
17+
force_https = true
18+
auto_stop_machines = false
19+
auto_start_machines = true
20+
min_machines_running = 1
21+
processes = ["app"]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cycler==0.12.1
1010
ezdxf==1.4.2
1111
Flask==3.1.2
1212
fonttools==4.59.2
13+
gunicorn==23.0.0
1314
itsdangerous==2.2.0
1415
Jinja2==3.1.6
1516
kiwisolver==1.4.9

0 commit comments

Comments
 (0)