Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (52 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (52 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# =============================================================================
# CiteSight Docker Build
# Multi-stage build: Node.js for building, nginx for serving
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Build
# -----------------------------------------------------------------------------
FROM node:18-alpine AS builder
WORKDIR /app
# Install dependencies first (better caching)
COPY package.json package-lock.json* ./
RUN npm ci --silent
# Copy source files
COPY . .
# Build arguments for VITE_ environment variables
# These get baked into the bundle at build time
ARG VITE_COURTLISTENER_API_KEY
ARG VITE_COURTLISTENER_BASE_URL=https://www.courtlistener.com/api/rest/v4
ARG VITE_LLAMA_CLOUD_API_KEY
ARG VITE_BUILD_MODE=self-hosted
ARG VITE_TURNSTILE_SITE_KEY
# Set environment variables for build
ENV VITE_COURTLISTENER_API_KEY=$VITE_COURTLISTENER_API_KEY
ENV VITE_COURTLISTENER_BASE_URL=$VITE_COURTLISTENER_BASE_URL
ENV VITE_LLAMA_CLOUD_API_KEY=$VITE_LLAMA_CLOUD_API_KEY
ENV VITE_BUILD_MODE=$VITE_BUILD_MODE
ENV VITE_TURNSTILE_SITE_KEY=$VITE_TURNSTILE_SITE_KEY
# Build the application
RUN npm run build
# -----------------------------------------------------------------------------
# Stage 2: Serve
# -----------------------------------------------------------------------------
FROM nginx:alpine AS production
# Copy custom nginx configuration
COPY nginx/nginx.conf /etc/nginx/nginx.conf
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Create non-root user for security
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
touch /tmp/nginx.pid && \
chown -R nginx:nginx /tmp/nginx.pid
# Switch to non-root user
USER nginx
# Expose port 8080 (non-privileged)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]