-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (62 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
82 lines (62 loc) · 1.79 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Build stage
FROM node:24-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
curl \
build-base \
perl \
llvm-dev \
clang-dev
# Allow linking libclang on musl
ENV RUSTFLAGS="-C target-feature=-crt-static"
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
ARG POSTHOG_API_KEY
ARG POSTHOG_API_ENDPOINT
ENV VITE_PUBLIC_POSTHOG_KEY=$POSTHOG_API_KEY
ENV VITE_PUBLIC_POSTHOG_HOST=$POSTHOG_API_ENDPOINT
# Set working directory
WORKDIR /app
# Copy package files for dependency caching
COPY package*.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY frontend/package*.json ./frontend/
COPY npx-cli/package*.json ./npx-cli/
# Install pnpm and dependencies
RUN npm install -g pnpm && pnpm install
# Copy source code
COPY . .
# Build application
RUN npm run generate-types
RUN cd frontend && pnpm run build
RUN cargo build --release --bin server
# Runtime stage
FROM alpine:latest AS runtime
# Install runtime dependencies
RUN apk add --no-cache \
ca-certificates \
tini \
libgcc \
wget
# Create app user for security
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
# Copy binary from builder
COPY --from=builder /app/target/release/server /usr/local/bin/server
# Create repos directory and set permissions
RUN mkdir -p /repos && \
chown -R appuser:appgroup /repos
# Switch to non-root user
USER appuser
# Set runtime environment
ENV HOST=0.0.0.0
ENV PORT=3000
EXPOSE 3000
# Set working directory
WORKDIR /repos
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider "http://${HOST:-localhost}:${PORT:-3000}" || exit 1
# Run the application
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["server"]