-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (34 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
45 lines (34 loc) · 1.28 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
# Usage:
# - Build: docker build -t <image-name> .
# - Run: docker run -it --env-file <env-file> <image-name>
# OR
# docker run -it -e KEY1=value1 -e KEY2=value2 <image-name>
# OR
# docker run -it --env-file .env <image-name>
#
# To backfill leverage tokens, set the BACKFILL_LEVERAGE_TOKENS environment variable to an array of addresses
# -------------------------------------
# ---------- 1️⃣ Build stage ----------
# -------------------------------------
FROM node:22-alpine AS builder
WORKDIR /app
# Only copy what is needed to calculate the dependency tree
COPY package*.json ./
# Install all deps (incl. dev) so TypeScript, ESLint, etc. can run
RUN npm ci
# Bring in the source and build the JS bundle
COPY . .
RUN npm run build
# ---------------------------------------
# ---------- 2️⃣ Runtime stage ----------
# ---------------------------------------
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Copy the compiled output *and* the pruned node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json .
# Environment variables will be passed through from the host to the container
# and will be available as process.env in the Node.js application
CMD ["npm", "start"]