-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (44 loc) · 1.16 KB
/
Dockerfile
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
FROM oven/bun:1.1-debian AS builder
WORKDIR /app
# Build arguments
ARG BUILD_DATE
ARG VERSION
# Copy dependency files
COPY package.json bun.lockb tsconfig.json ./
# Install dependencies
RUN bun install --no-install-postinstall
# Copy source code
COPY src/ ./src/
# Second stage
FROM oven/bun:1.1-debian
# Install required packages
USER root
RUN apt-get update && apt-get install -y \
iputils-ping \
ncurses-bin \
&& rm -rf /var/lib/apt/lists/* \
&& setcap cap_net_raw+ep /bin/ping
WORKDIR /app
# Labels
LABEL build_date=$BUILD_DATE version=$VERSION
# Copy from builder
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/src ./src
COPY --from=builder /app/tsconfig.json ./
COPY --from=builder /app/package.json ./package.json
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create necessary directories
RUN mkdir -p /app/tmp && chown -R bun:bun /app
# Create volume for data
VOLUME ["/app/data"]
# Switch to non-root user
USER bun:bun
# Environment
ENV NODE_ENV=production
ENV ENVIRONMENT=Docker
ENV TERM=xterm-256color
ENV FORCE_COLOR=1
ENV COLORTERM=truecolor
ENTRYPOINT ["/entrypoint.sh"]