Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/package - part 1 #161

Merged
merged 38 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
08624a2
chore: Enable static export for Next.js frontend
srijanpatel Feb 13, 2025
cea914d
chore: Update frontend .gitignore to exclude Next.js output directory
srijanpatel Feb 13, 2025
3de47df
chore: rename `backend/app` to `backend/pyspur` to prep for packaging
srijanpatel Feb 13, 2025
4bc94e4
chore: Update Alembic env.py import paths to use `pyspur` namespace
srijanpatel Feb 13, 2025
36481c0
chore: Update import paths in evaluator.py to use relative imports
srijanpatel Feb 13, 2025
51b94ad
chore: Update import path in google_sheets_read.py to use relative im…
srijanpatel Feb 13, 2025
65a6383
chore: Update import path in _model_info.py to use relative import
srijanpatel Feb 13, 2025
c88aa50
chore: Add Even Better TOML extension to devcontainer
srijanpatel Feb 13, 2025
6b1cf5c
chore: Update import paths to use `pyspur` namespace in backend confi…
srijanpatel Feb 14, 2025
7102c97
chore: Add pyproject.toml for PySpur package configuration
srijanpatel Feb 14, 2025
e3565e9
chore: sync devcontainer with pyproject.toml
srijanpatel Feb 14, 2025
351ade5
chore: Enhance Ruff linting configuration in pyproject.toml remove isort
srijanpatel Feb 14, 2025
66e2ab6
format: using ruff
srijanpatel Feb 14, 2025
f89bc86
chore: Add empty __init__.py for pyspur package
srijanpatel Feb 14, 2025
c4af378
chore: Update pyproject.toml with project metadata and dependencies
srijanpatel Feb 14, 2025
e3fc30a
Merge remote-tracking branch 'origin/main' into feat/package
srijanpatel Feb 14, 2025
444dcd8
chore: Add .gitignore to static directory to ignore generated files
srijanpatel Feb 14, 2025
7999d3e
fix: use regex to replace root package
srijanpatel Feb 14, 2025
a8e25ce
feat: restructure FastAPI application to separate API and static file…
srijanpatel Feb 14, 2025
26306b5
fix: update proxy_pass path for API service in Nginx configuration
srijanpatel Feb 14, 2025
f8d9154
chore: minor cleanup
srijanpatel Feb 14, 2025
5dc3a58
Merge remote-tracking branch 'origin/main' into feat/package
srijanpatel Feb 14, 2025
ee97067
Merge remote-tracking branch 'origin/main' into feat/package
srijanpatel Feb 15, 2025
c346008
chore: move reddit nodes to pyspur
srijanpatel Feb 15, 2025
b6991b6
chore: update .gitignore to include Ruff cache
srijanpatel Feb 15, 2025
8b950fb
chore: move Dockerfiles to project root
srijanpatel Feb 15, 2025
4e480b3
chore: consolidate .dockerignore files into a single file at project …
srijanpatel Feb 15, 2025
6b6ef66
chore: add frontend build stage to Dockerfile.backend
srijanpatel Feb 15, 2025
cdb291d
chore: remove frontend build stage from release workflow
srijanpatel Feb 15, 2025
a823c72
chore: update environment configuration and remove nginx service from…
srijanpatel Feb 15, 2025
ea92dd7
chore: clean up stale static files before building
srijanpatel Feb 15, 2025
caf794b
feat: hand-roll static file serving with FastAPI to work with dynamic…
srijanpatel Feb 15, 2025
e187780
feat: add staging environment configuration with Docker Compose
srijanpatel Feb 15, 2025
5f5889e
refactor: use pathlib everywhere in static file router
srijanpatel Feb 15, 2025
d18f494
fix: resolve base path for package discovery to ensure correct direct…
srijanpatel Feb 15, 2025
437df3a
Merge remote-tracking branch 'origin/main' into feat/package
srijanpatel Feb 15, 2025
b5ff66b
move anki node to pyspur directory
srijanpatel Feb 15, 2025
fd09c47
refactor: remove debug print statements from frontend serving logic
srijanpatel Feb 15, 2025
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
19 changes: 15 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@
"ms-python.python",
"ms-python.black-formatter",
"ms-python.pylance",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"tamasfe.even-better-toml",
// Frontend extensions
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode.vscode-typescript-next"
],
"settings": {
// Python analysis settings
"python.analysis.autoImportCompletions": true,
"python.analysis.autoImportUserSymbols": true,
"python.analysis.importFormat": "relative",
"python.analysis.importSortEnabled": true,
"python.analysis.importSortOrder": ["stdlib", "thirdparty", "local"],
"python.analysis.typeCheckingMode": "strict",
"python.defaultInterpreterPath": "/usr/local/bin/python",

// Python linting and formatting
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.ruffEnabled": true,

// TypeScript settings
"typescript.tsdk": "/pyspur/frontend/node_modules/typescript/lib",
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.projectRoot": "/pyspur/frontend",
Expand All @@ -50,7 +57,11 @@
"[python]": {
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll.ruff": "always"
}
},
"[json]": {
"editor.quickSuggestions": {
Expand Down
88 changes: 88 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Version control
.git
.gitignore

# Dependencies
**/node_modules
**/__pycache__
**/*.pyc
**/*.pyo
**/*.pyd
**/*.so
**/.Python
**/env
**/venv
**/.env
**/.env.local
**/.env.development.local
**/.env.test.local
**/.env.production.local

# Python specific
**/develop-eggs
**/eggs
**/.eggs
**/parts
**/sdist
**/var
**/wheels
**/*.egg-info
**/.installed.cfg
**/*.egg

# Build outputs
**/dist
**/build
**/.next
**/out
**/*.egg-info

# Development/IDE files
**/.idea
**/.vscode
**/.DS_Store
**/*.swp
**/*.swo

# Docker files
**/Dockerfile*
**/.dockerignore
docker-compose*.yml

# Test files
**/__tests__
**/test
**/*.test.js
**/*.spec.js
**/*.test.py
**/*.spec.py
**/coverage
**/htmlcov

# Documentation
**/*.md
**/docs

# Logs
**/logs
**/*.log
**/npm-debug.log*
**/yarn-debug.log*
**/yarn-error.log*

# Cache
**/.cache
**/.npm
**/.eslintcache
**/.pytest_cache
**/__pycache__
**/.coverage

# Data directories
**/data
**/uploads
**/downloads

# Databases
**/*.db
**/sqlite/*.db
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ DEBUG=False
FRONTEND_PORT=3000
FRONTEND_HOST=0.0.0.0

# Nginx Configuration
# This is the port that will be used to access the application
NGINX_PORT=6080
# Application Port Configuration
# This is the port that will be exposed to access the PySpur application
PYSPUR_PORT=6080

# ======================
# Database Settings
Expand Down
26 changes: 3 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
env:
REGISTRY: ghcr.io
BACKEND_IMAGE_NAME: ${{ github.repository }}-backend
FRONTEND_IMAGE_NAME: ${{ github.repository }}-frontend

jobs:
build-and-push:
Expand Down Expand Up @@ -36,31 +35,12 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Extract metadata (tags, labels) for Frontend
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push Backend image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
context: .
file: ./Dockerfile.backend
push: true
target: production
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}

- name: Build and push Frontend image
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
target: production
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
labels: ${{ steps.meta-backend.outputs.labels }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ cython_debug/
#.idea/

.DS_Store
.vscode
.vscode

# Ruff cache
**/.ruff_cache/
33 changes: 33 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:3.12-slim AS base
RUN apt-get update && apt-get install -y \
libpq-dev \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /pyspur/backend
COPY backend/requirements.txt .
RUN pip install -r requirements.txt

# Development stage
FROM base AS development
ENV PYTHONPATH=/pyspur/backend
# Development-specific instructions here

# Frontend build stage
FROM node:23-alpine AS frontend-builder
WORKDIR /pyspur/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ .
RUN npm run build

# Production stage
FROM base AS production
ENV PYTHONPATH=/pyspur/backend
COPY backend/ .
# Copy frontend static files from frontend build stage
RUN mkdir -p /pyspur/backend/pyspur/static
RUN rm -rf /pyspur/backend/pyspur/static/*
COPY --from=frontend-builder /pyspur/frontend/out/ /pyspur/backend/pyspur/static/
# Production-specific instructions here
7 changes: 3 additions & 4 deletions frontend/Dockerfile → Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Base stage
FROM node:23-alpine AS base
WORKDIR /pyspur/frontend
COPY package*.json ./
COPY frontend/package*.json ./

# Development stage
FROM base AS development
Expand All @@ -11,6 +10,6 @@ RUN npm install
# Production stage
FROM base AS production
RUN npm ci --only=production
COPY . .
COPY frontend/ .
RUN npm run build
# Production-specific instructions here
# Production-specific instructions here
46 changes: 0 additions & 46 deletions backend/.dockerignore

This file was deleted.

20 changes: 0 additions & 20 deletions backend/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion backend/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[alembic]
# path to migration scripts
# Use forward slashes (/) also on windows to provide an os agnostic path
script_location = app/models/management/alembic/
script_location = pyspur/models/management/alembic/

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
Expand Down
49 changes: 0 additions & 49 deletions backend/app/api/main.py

This file was deleted.

Loading