Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ deps.zig

# User-specific configuration
upstreams.json
upstreams-*.json
!upstreams.example.json

# Frontend
web/node_modules/
web-dist/
*.local
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ FROM alpine:latest AS builder
RUN apk add --no-cache \
curl \
xz \
bash
bash \
nodejs \
npm

# Install Zig 0.14.1
ARG ZIG_VERSION=0.14.1
Expand All @@ -23,9 +25,14 @@ WORKDIR /build
COPY build.zig build.zig.zon ./
COPY src/ ./src/

# Build the project
# Build the backend
RUN zig build -Doptimize=ReleaseSafe

# Copy and build frontend
COPY web/ ./web/
COPY Makefile ./
RUN cd web && npm ci && npm run build

# Stage 2: Runtime stage
FROM alpine:latest

Expand All @@ -40,12 +47,15 @@ RUN addgroup -g 1000 leanpoint && \
adduser -D -u 1000 -G leanpoint leanpoint

# Create directories
RUN mkdir -p /etc/leanpoint /var/lib/leanpoint && \
chown -R leanpoint:leanpoint /etc/leanpoint /var/lib/leanpoint
RUN mkdir -p /etc/leanpoint /var/lib/leanpoint /usr/share/leanpoint/web && \
chown -R leanpoint:leanpoint /etc/leanpoint /var/lib/leanpoint /usr/share/leanpoint

# Copy binary from builder
COPY --from=builder /build/zig-out/bin/leanpoint /usr/local/bin/leanpoint

# Copy web UI from builder
COPY --from=builder /build/web-dist/ /usr/share/leanpoint/web/

# Copy example config
COPY upstreams.example.json /etc/leanpoint/upstreams.example.json

Expand All @@ -58,5 +68,5 @@ EXPOSE 5555
# Set working directory
WORKDIR /var/lib/leanpoint

# Default command
CMD ["leanpoint", "--help"]
# Default command - serve with web UI
CMD ["leanpoint", "--upstreams-config", "/etc/leanpoint/upstreams.json", "--static-dir", "/usr/share/leanpoint/web"]
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.PHONY: all build build-backend build-web install-web clean clean-web run dev help

all: build

help:
@echo "Leanpoint Monorepo Build System"
@echo ""
@echo "Available targets:"
@echo " make build - Build both backend and frontend"
@echo " make build-backend - Build only the Zig backend"
@echo " make build-web - Build only the frontend"
@echo " make install-web - Install frontend dependencies"
@echo " make dev - Run frontend dev server (hot reload)"
@echo " make run - Run the backend"
@echo " make clean - Clean all build artifacts"
@echo " make clean-web - Clean only frontend artifacts"
@echo ""

# Install frontend dependencies
install-web:
@echo "📦 Installing frontend dependencies..."
cd web && npm install

# Build frontend (production)
build-web: install-web
@echo "🎨 Building frontend..."
cd web && npm run build
@echo "✅ Frontend built successfully to ./web-dist/"

# Build backend
build-backend:
@echo "⚡ Building Zig backend..."
zig build
@echo "✅ Backend built successfully to ./zig-out/bin/leanpoint"

# Build everything
build: build-backend build-web
@echo "✅ All components built successfully!"

# Run frontend dev server
dev:
@echo "🚀 Starting frontend dev server..."
cd web && npm run dev

# Run backend
run:
@echo "🚀 Running leanpoint..."
./zig-out/bin/leanpoint --upstreams-config upstreams.json --static-dir web-dist

# Clean frontend artifacts
clean-web:
@echo "🧹 Cleaning frontend artifacts..."
rm -rf web/node_modules web-dist

# Clean all artifacts
clean: clean-web
@echo "🧹 Cleaning backend artifacts..."
rm -rf zig-out zig-cache
@echo "✅ All artifacts cleaned!"
Loading