-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.06 KB
/
Dockerfile
File metadata and controls
44 lines (35 loc) · 1.06 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
# Build stage
FROM oven/bun:1.3.10 AS builder
WORKDIR /usr/src
# Copy source files
COPY ./app ./app
COPY ./config ./config
COPY ./docs ./docs
COPY ./dist ./dist
COPY ./tsconfig.docker.json ./tsconfig.json
# [optional] Run tests and build
# ENV NODE_ENV=production
# RUN bun test
# RUN bun run build
# Final stage
FROM oven/bun:1.3.10 AS release
WORKDIR /usr/src
# Copy built files from builder stage
COPY --from=builder /usr/src/app ./app
COPY --from=builder /usr/src/config ./config
COPY --from=builder /usr/src/docs ./docs
COPY --from=builder /usr/src/dist ./dist
COPY --from=builder /usr/src/tsconfig.json ./tsconfig.json
# Set up storage directory
USER root
RUN mkdir -p ./storage
COPY --chown=bun:bun ./storage ./storage
# Install curl for the healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl && apt-get clean && rm -rf /var/lib/apt/lists/*
# Add storage volume for logs and other files
VOLUME ["/usr/src/storage"]
# Switch to non-root user
USER bun
# Expose port and set entrypoint
EXPOSE 3000/tcp
ENTRYPOINT ["bun", "run", "dist/index.js"]