fix: optimize Dockerfile - use --production for deps, slim base image - Use bun install --production to exclude dev dependencies - Use oven/bun:1-slim instead of oven/bun:1 (smaller base) - Use --no-install-recommends for apt packages - Clean up apt cache in same layer - Rename REPOS_PATH to GIT_REPOS_PATH for consistency

swadhinbiswas committed 3 months ago
78e882e
1 parent e0b3681
commit 78e882e
1 file changed
+8 -7
Showing 1 changed file+8-7
▼Dockerfile
+8-7
12
12
COPY package.json bun.lock ./
13
13
COPY cli/package.json ./cli/package.json
14
14
RUN for i in 1 2 3; do \
15
- bun install --frozen-lockfile && break || \
15
+ bun install --frozen-lockfile --production && break || \
16
16
(echo "bun install attempt $i failed, retrying in 10s..." && sleep 10); \
17
17
done
18
18
24
24
RUN bun run build
25
25
26
26
# Production image
27
-FROM oven/bun:1 AS runner
27
+FROM oven/bun:1-slim AS runner
28
28
WORKDIR /app
29
29
30
30
# Install git, ssh, and bash (needed for git operations and entrypoint)
31
-RUN apt-get update && apt-get install -y git openssh-client bash && rm -rf /var/lib/apt/lists/*
31
+RUN apt-get update && apt-get install -y --no-install-recommends git openssh-client bash && \
32
+ rm -rf /var/lib/apt/lists/*
32
33
33
34
# Create data directories
34
-RUN mkdir -p /data/repos /data/storage /data/cache /data/ssh && \
35
+RUN mkdir -p /data/repositories /data/storage /data/cache /data/ssh && \
35
36
chown -R bun:bun /data
36
37
37
-# Copy built application
38
+# Copy only what's needed for runtime
38
39
COPY --from=builder --chown=bun:bun /app/dist ./dist
39
-COPY --from=builder --chown=bun:bun /app/node_modules ./node_modules
40
+COPY --from=deps --chown=bun:bun /app/node_modules ./node_modules
40
41
COPY --from=builder --chown=bun:bun /app/package.json ./
41
42
42
43
# Copy drizzle config and schema for migrations
51
52
ENV HOST=0.0.0.0
52
53
ENV PORT=4321
53
54
ENV DATA_DIR=/data
54
-ENV REPOS_PATH=/data/repos
55
+ENV GIT_REPOS_PATH=/data/repositories
55
56
ENV STORAGE_PATH=/data/storage
56
57
ENV CACHE_PATH=/data/cache
57
58
ENV SSH_PATH=/data/ssh
58
59