-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (45 loc) · 1.44 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (45 loc) · 1.44 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
# ============================================
# bunQ Dockerfile
# Multi-stage build for optimal image size
# ============================================
# Stage 1: Build
FROM oven/bun:1-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json bun.lock* ./
# Install dependencies (ignore prepare script - no git in container)
RUN bun install --frozen-lockfile --ignore-scripts
# Copy source code
COPY src/ ./src/
COPY tsconfig.json ./
# Type check
RUN bun run typecheck
# Build single executable
RUN bun build --compile --minify src/main.ts --outfile bunqueue
# ============================================
# Stage 2: Production
FROM oven/bun:1-alpine AS production
WORKDIR /app
# Create non-root user for security
RUN addgroup -g 1001 bunqueue && \
adduser -D -u 1001 -G bunqueue bunqueue
# Create data directory
RUN mkdir -p /app/data && chown -R bunqueue:bunqueue /app
# Copy built executable from builder
COPY --from=builder --chown=bunqueue:bunqueue /app/bunqueue ./bunqueue
# Switch to non-root user
USER bunqueue
# Environment variables
ENV TCP_PORT=6789
ENV HTTP_PORT=6790
ENV DATA_PATH=/app/data/bunqueue.db
ENV NODE_ENV=production
# Expose ports
EXPOSE 6789 6790
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:6790/health || exit 1
# Volume for persistent data
VOLUME ["/app/data"]
# Run the server
ENTRYPOINT ["./bunqueue"]