gionuibk commited on
Commit
eda0bfa
·
verified ·
1 Parent(s): 0f91273

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +91 -0
Dockerfile ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /!\ NOTICE /!\
2
+
3
+ # Many of the developers DO NOT USE the Dockerfile or image.
4
+ # While we do test new changes to Docker configuration, it's
5
+ # possible that future changes to the repo might break it.
6
+ # When changing this file, please try to make it as resiliant
7
+ # to such changes as possible; developers shouldn't need to
8
+ # worry about Docker unless the build/run process changes.
9
+
10
+ # Build stage
11
+ FROM node:24-alpine AS build
12
+
13
+ # Install build dependencies
14
+ RUN apk add --no-cache git python3 make g++ \
15
+ && ln -sf /usr/bin/python3 /usr/bin/python
16
+
17
+ # Set up working directory
18
+ WORKDIR /app
19
+
20
+ # Copy package.json and package-lock.json
21
+ COPY package.json package-lock.json ./
22
+
23
+ # Fail early if lockfile or manifest is missing
24
+ RUN test -f package.json && test -f package-lock.json
25
+
26
+ # Copy the source files
27
+ COPY . .
28
+
29
+ # Install mocha
30
+ RUN npm i -g npm@latest
31
+ RUN npm install -g mocha
32
+
33
+ # Install node modules
34
+ RUN npm cache clean --force && \
35
+ for i in 1 2 3; do \
36
+ npm ci && break || \
37
+ if [ $i -lt 3 ]; then \
38
+ sleep 15; \
39
+ else \
40
+ LOG_DIR="$(npm config get cache | tr -d '\"')/_logs"; \
41
+ echo "npm install failed; dumping logs from $LOG_DIR"; \
42
+ if [ -d "$LOG_DIR" ]; then \
43
+ ls -al "$LOG_DIR" || true; \
44
+ cat "$LOG_DIR"/* || true; \
45
+ else \
46
+ echo "Log directory not found (npm cache: $(npm config get cache))"; \
47
+ fi; \
48
+ exit 1; \
49
+ fi; \
50
+ done
51
+
52
+ # Run the build command if necessary
53
+ RUN cd src/gui && npm run build && cd -
54
+
55
+ # Production stage
56
+ FROM node:24-alpine
57
+
58
+ # Set labels
59
+ LABEL repo="https://github.com/HeyPuter/puter"
60
+ LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
61
+ LABEL version="1.2.46-beta-1"
62
+
63
+ # Install git (required by Puter to check version)
64
+ RUN apk add --no-cache git
65
+
66
+ # Set up working directory
67
+ RUN mkdir -p /opt/puter/app
68
+ WORKDIR /opt/puter/app
69
+
70
+ # Copy built artifacts and necessary files from the build stage
71
+ COPY --from=build /app/src/gui/dist ./dist
72
+ COPY --from=build /app/node_modules ./node_modules
73
+ COPY . .
74
+
75
+ # Set permissions
76
+ RUN chown -R node:node /opt/puter/app
77
+ USER node
78
+
79
+ EXPOSE 7860
80
+
81
+ HEALTHCHECK --interval=30s --timeout=3s \
82
+ CMD wget --no-verbose --tries=1 --spider http://localhost:7860/test || exit 1
83
+
84
+ ENV NO_VAR_RUNTUME=1
85
+
86
+ # Attempt to fix `lru-cache@11.0.2` missing after build stage
87
+ # by doing a redundant `npm install` at this stage
88
+ RUN npm install
89
+
90
+ ENV PORT=7860
91
+ CMD ["npm", "start"]