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
39 changes: 39 additions & 0 deletions .github/workflows/koyeb-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy to Koyeb

on:
push:
branches:
- main

env:
KOYEB_APP_NAME: duckdb-spawn
KOYEB_SERVICE_NAME: api

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Koyeb CLI
run: |
curl -fsSL https://cli.koyeb.com/install.sh | sh
koyeb --version

- name: Login to Koyeb
run: koyeb login ${{ secrets.KOYEB_TOKEN }}

- name: Build and Deploy to Koyeb
run: |
koyeb service update $KOYEB_APP_NAME/$KOYEB_SERVICE_NAME \
--docker ${{ github.repository }}:${{ github.sha }} \
--ports 8000:8000 \
--env DATABASE_URL=/data/duckdb_spawn.db \
--env PYTHONUNBUFFERED=1 \
--env LOG_LEVEL=info \
--env ENVIRONMENT=staging \
--memory 512Mi \
--cpu 0.1 \
--region fra \
--instance-type nano
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-traditional \
&& rm -rf /var/lib/apt/lists/*

# Copy only the application requirements file
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application source code only (excluding infrastructure)
# Copy the application source code
COPY src/ src/

# Create directories for data and logs with proper permissions
Expand All @@ -31,8 +31,7 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \

# Set environment variables
ENV PYTHONPATH=/app \
PYTHONUNBUFFERED=1 \
DATABASE_URL=/data/duckdb_spawn.db
PYTHONUNBUFFERED=1

# Run the application
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
16 changes: 2 additions & 14 deletions infrastructure/pulumi/Pulumi.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
config:
duckdb-spawn:apiPort: 8000
duckdb-spawn:prometheusPort: 9090
duckdb-spawn:environment: dev
duckdb-spawn:logLevel: debug
duckdb-spawn:resourceLimits:
memory: "536870912"
cpuShares: "100"
duckdb-spawn:containerRegistry: localhost:5001
docker: "desktop-linux"

networks:
registry:
driver: bridge
environment:
- duckdb-spawn/dev
20 changes: 14 additions & 6 deletions infrastructure/pulumi/Pulumi.staging.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
config:
duckdb-spawn:apiPort: 8000
duckdb-spawn:prometheusPort: 9090
duckdb-spawn:environment: staging
duckdb-spawn:logLevel: info
duckdb-spawn:apiPort: "8000"
duckdb-spawn:prometheusPort: "9090"
duckdb-spawn:environment: "staging"
duckdb-spawn:logLevel: "info"
duckdb-spawn:resourceLimits:
cpu: "1.0"
memory: "1Gi"
memory: "536870912"
cpuShares: "100"
docker:context: "desktop-linux"
koyeb:
app_name: "duckdb-spawn"
service_name: "api"
instance_type: "nano"
regions: ["fra"]
ports:
- "8000:8000"
20 changes: 20 additions & 0 deletions infrastructure/pulumi/koyeb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: duckdb-spawn
services:
- name: api
instance_type: nano
regions: ["fra"]
ports:
- port: 8000
protocol: http
env:
- name: DATABASE_URL
value: /data/duckdb_spawn.db
- name: PYTHONUNBUFFERED
value: "1"
- name: LOG_LEVEL
value: info
- name: ENVIRONMENT
value: staging
resources:
memory: 512Mi
cpu: 0.1