Rewrite from Go + vanilla JS to Python (FastAPI) + React (TypeScript)

- Backend: Python 3.12 with FastAPI, SQLAlchemy, boto3
- Frontend: React 18 with TypeScript, Vite build tooling
- Updated Dockerfile for multi-stage Node + Python build
- Updated CI pipeline for Python backend
- Removed old Go code (cmd/, internal/, go.mod, go.sum)
- Updated README with new tech stack documentation
This commit is contained in:
Mondo Diaz
2025-12-05 17:16:43 -06:00
parent 343f7bfc59
commit 2261bfc830
45 changed files with 2104 additions and 3359 deletions

View File

@@ -1,39 +1,41 @@
# Build stage
FROM golang:1.22-alpine AS builder
# Frontend build stage
FROM node:20-alpine AS frontend-builder
RUN apk add --no-cache git ca-certificates
WORKDIR /app/frontend
WORKDIR /app
# Copy package files
COPY frontend/package*.json ./
RUN npm install
# Copy go mod files
COPY go.mod go.sum* ./
RUN go mod download
# Copy frontend source
COPY frontend/ ./
# Copy source code
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s" \
-o /orchard-server \
./cmd/orchard-server
# Build frontend
RUN npm run build
# Runtime stage
FROM alpine:3.19
FROM python:3.12-slim
RUN apk add --no-cache ca-certificates tzdata
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN addgroup -g 1000 orchard && \
adduser -u 1000 -G orchard -s /bin/sh -D orchard
RUN groupadd -g 1000 orchard && \
useradd -u 1000 -g orchard -s /bin/bash -m orchard
WORKDIR /app
# Copy binary from builder
COPY --from=builder /orchard-server /app/orchard-server
# Copy requirements and install Python dependencies
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy migrations
COPY --from=builder /app/migrations /app/migrations
# Copy backend source
COPY backend/ ./backend/
# Copy frontend build
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Set ownership
RUN chown -R orchard:orchard /app
@@ -43,6 +45,6 @@ USER orchard
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
CMD curl -f http://localhost:8080/health || exit 1
ENTRYPOINT ["/app/orchard-server"]
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8080"]