-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (50 loc) · 1.51 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (50 loc) · 1.51 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
# Stage 1: Build
FROM oven/bun:1 AS builder
WORKDIR /app
# Install Node.js repository and build dependencies
RUN apt-get update && \
apt-get install -y \
curl \
python3 \
make \
g++ \
gcc \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/bin/python3 /usr/bin/python
# Copy only the necessary files
COPY package*.json ./
COPY tsconfig.json ./
COPY src ./src
COPY scripts/decrypt.ts ./scripts/
COPY scripts/genTypes.sh ./scripts/
COPY config ./config
# Make genTypes.sh executable
RUN chmod +x ./scripts/genTypes.sh
# Generate types and install dependencies
RUN mkdir -p src/types/modules && \
npm install && \
./scripts/genTypes.sh && \
bun install --production
# Stage 2: Production
FROM oven/bun:1-slim
WORKDIR /app
# Copy only runtime files
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/src ./src
COPY --from=builder /app/scripts/decrypt.ts ./scripts/
COPY --from=builder /app/config ./config
COPY --from=builder /app/tsconfig.json ./
# Set environment variables
ENV NODE_ENV=production
# Create non-root user for security (Debian syntax)
RUN groupadd -r app && \
useradd -r -g app -s /bin/false app && \
chown -R app:app /app
USER app
# Use ENTRYPOINT to run TypeScript directly with Bun
ENTRYPOINT ["bun", "run", "scripts/decrypt.ts"]
# Default to showing help/usage if no args provided
CMD ["--help"]