-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (50 loc) · 1.96 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (50 loc) · 1.96 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
# Pull Docker CLI binary from official image to avoid apt repo complexity
FROM docker:27-cli AS docker-cli
# Multi-stage build using the repository's pinned Node LTS.
FROM node:24.20.0 AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY tsconfig.json tsconfig.eslint.json vite.config.ts postcss.config.js tailwind.config.ts components.json ./
COPY scripts/check-bundle-budget.mjs ./scripts/check-bundle-budget.mjs
COPY public ./public
COPY client ./client
COPY server ./server
COPY shared ./shared
RUN npm run build
########################################
# Production image
FROM node:24.20.0-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV ARDUINO_CACHE_DIR=/app/server/arduino-cache
# 1. Copy Docker CLI binary from official image (no apt repo setup needed)
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
# 2. Install system tools and Arduino CLI
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
tar \
xz-utils \
g++ \
&& curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh \
&& mkdir -p /home/node/.arduino15 \
&& chown -R node:node /home/node/.arduino15 \
&& su node -c 'HOME=/home/node arduino-cli config init' \
&& su node -c 'HOME=/home/node arduino-cli core update-index' \
&& su node -c 'HOME=/home/node arduino-cli core install arduino:avr' \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app/server/arduino-cache /app/storage/binaries /app/temp
# Copy built artifacts
COPY --from=builder /app/dist ./dist
# Copy package metadata and install dependencies
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --legacy-peer-deps --ignore-scripts \
&& chown -R node:node /app \
&& usermod -aG root node
# Run as non-root user for production
# node:slim already provides a 'node' user at UID 1000
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]