Containerize frontend
This commit is contained in:
parent
92b3a5bc85
commit
cb565b5ac8
4 changed files with 74 additions and 36 deletions
17
.dockerignore
Normal file
17
.dockerignore
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*.md
|
||||||
|
.env*
|
||||||
|
!.env.example
|
||||||
|
server/
|
||||||
|
authentik/
|
||||||
|
caddy/
|
||||||
|
scripts/
|
||||||
|
docs/
|
||||||
|
tests/
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
Caddyfile
|
||||||
|
docker-compose*.yml
|
||||||
41
Dockerfile
Normal file
41
Dockerfile
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Kaboot Frontend - Multi-stage Production Build
|
||||||
|
#
|
||||||
|
# Build:
|
||||||
|
# docker build \
|
||||||
|
# --build-arg VITE_API_URL=https://kaboot.example.com \
|
||||||
|
# --build-arg VITE_BACKEND_URL=https://kaboot.example.com \
|
||||||
|
# --build-arg VITE_AUTHENTIK_URL=https://auth.example.com \
|
||||||
|
# -t kaboot-frontend .
|
||||||
|
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --silent
|
||||||
|
|
||||||
|
COPY index.html tsconfig.json vite.config.ts postcss.config.mjs ./
|
||||||
|
COPY src/ ./src/
|
||||||
|
COPY components/ ./components/
|
||||||
|
COPY hooks/ ./hooks/
|
||||||
|
COPY public/ ./public/
|
||||||
|
|
||||||
|
ARG VITE_API_URL
|
||||||
|
ARG VITE_BACKEND_URL
|
||||||
|
ARG VITE_AUTHENTIK_URL
|
||||||
|
ARG VITE_OIDC_CLIENT_ID=kaboot-spa
|
||||||
|
ARG VITE_OIDC_APP_SLUG=kaboot
|
||||||
|
ARG GEMINI_API_KEY
|
||||||
|
|
||||||
|
ENV VITE_API_URL=$VITE_API_URL \
|
||||||
|
VITE_BACKEND_URL=$VITE_BACKEND_URL \
|
||||||
|
VITE_AUTHENTIK_URL=$VITE_AUTHENTIK_URL \
|
||||||
|
VITE_OIDC_CLIENT_ID=$VITE_OIDC_CLIENT_ID \
|
||||||
|
VITE_OIDC_APP_SLUG=$VITE_OIDC_APP_SLUG \
|
||||||
|
GEMINI_API_KEY=$GEMINI_API_KEY
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM caddy:2-alpine
|
||||||
|
COPY --from=builder /app/dist /srv/frontend
|
||||||
|
EXPOSE 80 443
|
||||||
|
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
||||||
|
|
@ -1,28 +1,22 @@
|
||||||
# Caddy Reverse Proxy for Kaboot Production
|
|
||||||
#
|
|
||||||
# This compose file adds Caddy as a reverse proxy with automatic HTTPS.
|
|
||||||
# Use with docker-compose.prod.yml using the -f flag.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# docker compose -f docker-compose.prod.yml -f docker-compose.caddy.yml up -d
|
|
||||||
#
|
|
||||||
# Prerequisites:
|
|
||||||
# 1. Copy Caddyfile.example to Caddyfile and update domains
|
|
||||||
# 2. Build the frontend: npm run build
|
|
||||||
# 3. Update your domain DNS to point to your server
|
|
||||||
# 4. See docs/PRODUCTION.md for full instructions
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
caddy:
|
kaboot-frontend:
|
||||||
image: caddy:2-alpine
|
build:
|
||||||
container_name: kaboot-caddy
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_API_URL: https://${KABOOT_DOMAIN}
|
||||||
|
VITE_BACKEND_URL: https://${KABOOT_DOMAIN}
|
||||||
|
VITE_AUTHENTIK_URL: https://${AUTH_DOMAIN}
|
||||||
|
VITE_OIDC_CLIENT_ID: kaboot-spa
|
||||||
|
VITE_OIDC_APP_SLUG: kaboot
|
||||||
|
GEMINI_API_KEY: ${GEMINI_API_KEY:-}
|
||||||
|
container_name: kaboot-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
- ./dist:/srv/frontend:ro
|
|
||||||
- ./caddy/data:/data
|
- ./caddy/data:/data
|
||||||
- ./caddy/config:/config
|
- ./caddy/config:/config
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,10 @@ cat > .env << EOF
|
||||||
# Kaboot Production Configuration
|
# Kaboot Production Configuration
|
||||||
# Generated by setup-prod.sh on $(date)
|
# Generated by setup-prod.sh on $(date)
|
||||||
|
|
||||||
|
# Domain Configuration (used by docker-compose for frontend build)
|
||||||
|
KABOOT_DOMAIN=${KABOOT_DOMAIN}
|
||||||
|
AUTH_DOMAIN=${AUTH_DOMAIN}
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
PG_PASS=${PG_PASS}
|
PG_PASS=${PG_PASS}
|
||||||
PG_USER=authentik
|
PG_USER=authentik
|
||||||
|
|
@ -229,29 +233,12 @@ if [ -f "$DEV_BLUEPRINT" ]; then
|
||||||
print_success "Removed development blueprint"
|
print_success "Removed development blueprint"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_step "Installing frontend dependencies..."
|
|
||||||
|
|
||||||
npm install --silent 2>/dev/null || npm install
|
|
||||||
|
|
||||||
print_success "Dependencies installed"
|
|
||||||
|
|
||||||
print_step "Building frontend with production URLs..."
|
|
||||||
|
|
||||||
VITE_API_URL="https://${KABOOT_DOMAIN}" \
|
|
||||||
VITE_BACKEND_URL="https://${KABOOT_DOMAIN}" \
|
|
||||||
VITE_AUTHENTIK_URL="https://${AUTH_DOMAIN}" \
|
|
||||||
VITE_OIDC_CLIENT_ID="kaboot-spa" \
|
|
||||||
VITE_OIDC_APP_SLUG="kaboot" \
|
|
||||||
npm run build --silent 2>/dev/null || npm run build
|
|
||||||
|
|
||||||
if [ -n "$GEMINI_API_KEY" ]; then
|
if [ -n "$GEMINI_API_KEY" ]; then
|
||||||
print_success "System AI will be available (key configured for backend)"
|
print_success "System AI will be available (key configured for backend)"
|
||||||
else
|
else
|
||||||
print_warning "No Gemini API key provided - users must configure their own"
|
print_warning "No Gemini API key provided - users must configure their own"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_success "Frontend built"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}${BOLD}════════════════════════════════════════════════════════════${NC}"
|
echo -e "${GREEN}${BOLD}════════════════════════════════════════════════════════════${NC}"
|
||||||
echo -e "${GREEN}${BOLD} Setup Complete!${NC}"
|
echo -e "${GREEN}${BOLD} Setup Complete!${NC}"
|
||||||
|
|
@ -280,7 +267,6 @@ echo "────────────────────────
|
||||||
echo " .env - Environment variables"
|
echo " .env - Environment variables"
|
||||||
echo " Caddyfile - Reverse proxy config"
|
echo " Caddyfile - Reverse proxy config"
|
||||||
echo " authentik/blueprints/kaboot-setup-production.yaml"
|
echo " authentik/blueprints/kaboot-setup-production.yaml"
|
||||||
echo " dist/ - Built frontend"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${BOLD}Next Steps${NC}"
|
echo -e "${BOLD}Next Steps${NC}"
|
||||||
echo "────────────────────────────────────────────────────────────"
|
echo "────────────────────────────────────────────────────────────"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue