-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (44 loc) · 1.54 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (44 loc) · 1.54 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
# syntax = docker/dockerfile:1
# ==========================================
# BASE STAGE - Common dependencies and setup
# ==========================================
FROM oven/bun:1.3.14 AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends unzip ca-certificates wget && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
WORKDIR /app
ENV NODE_ENV=production \
PORT=3000 \
BUN_RUNTIME_TRANSPILER_CACHE_PATH=/tmp/bun-transpiler-cache
# ==========================================
# BUILD STAGE - Compile and prepare the app
# ==========================================
FROM base AS build
ARG VERSION=dev
ENV VERSION=${VERSION}
COPY --link package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY --link . .
RUN bun run build && \
bun install --production --frozen-lockfile && \
touch .env
# ==========================================
# PRODUCTION STAGE - Final lightweight image
# ==========================================
FROM base
ARG VERSION=dev
ENV VERSION=${VERSION}
COPY --from=build /app/build ./build
COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/node_modules ./node_modules
EXPOSE ${PORT}
RUN groupadd --gid 1001 datum && \
useradd --uid 1001 --gid 1001 --no-create-home datum && \
chown -R datum:datum /app
USER datum
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1:${PORT}/ > /dev/null 2>&1 || exit 1
CMD ["bun", "run", "start"]