-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
80 lines (65 loc) · 1.58 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Build stage
FROM node:20-alpine AS build
WORKDIR /app
# Install all required build dependencies
RUN apk add --no-cache \
python3 \
make \
g++ \
linux-headers \
eudev-dev \
libusb-dev \
udev \
build-base \
libc6-compat \
libusb \
eudev \
gcc \
file-dev \
musl-dev
# Set build environment variables
ENV PYTHON=/usr/bin/python3
ENV NODE_GYP_FORCE_PYTHON=/usr/bin/python3
# Copy package files
COPY package.json yarn.lock ./
# Install dependencies with increased timeout
RUN yarn install --frozen-lockfile --network-timeout 300000
# Copy source files
COPY . .
# Build TypeScript and Vite
RUN yarn build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Install runtime dependencies including build tools needed for production install
RUN apk add --no-cache \
python3 \
make \
g++ \
linux-headers \
eudev-dev \
libusb-dev \
udev \
build-base \
libc6-compat \
libusb \
eudev
# Set Python path for production
ENV PYTHON=/usr/bin/python3
ENV NODE_GYP_FORCE_PYTHON=/usr/bin/python3
# Copy built files and production dependencies
COPY --from=build /app/dist ./dist
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/yarn.lock ./yarn.lock
# Install only production dependencies
RUN yarn install --production --frozen-lockfile --network-timeout 300000
# Environment setup
ENV NODE_ENV=production
ENV PORT=8080
ENV HOST=0.0.0.0
# Expose port
EXPOSE 8080
# Use a more production-ready server
RUN yarn add serve
# Start serve instead of preview
CMD ["yarn", "serve", "-s", "dist", "-l", "8080"]