-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
51 lines (36 loc) · 1.09 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
# Use the official Bun image
FROM oven/bun:1 as base
# Set the working directory
WORKDIR /app
# Copy package.json and bun.lockb for dependency installation
COPY package.json bun.lockb ./
# Install dependencies
RUN bun install --production --frozen-lockfile
# Copy the source code
COPY src ./src
COPY tsconfig.json ./
# Build the application
RUN bun run build
# Production stage
FROM oven/bun:1-slim as production
WORKDIR /app
# Copy built application from build stage
COPY --from=base /app/dist ./dist
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/package.json ./
# Create a non-root user for security
RUN addgroup --system --gid 1001 bunuser && \
adduser --system --uid 1001 bunuser
# Change ownership of the app directory
RUN chown -R bunuser:bunuser /app
# Switch to non-root user
USER bunuser
# Expose the port
EXPOSE 4000
# Set environment to production
ENV NODE_ENV=production
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:4000/ || exit 1
# Start the application
CMD ["bun", "dist/index.js"]