latterworks commited on
Commit
5528f30
·
verified ·
1 Parent(s): 9365132

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +78 -0
Dockerfile ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:23.9-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 ./
22
+
23
+ # Copy the source files
24
+ COPY . .
25
+
26
+ # Install mocha
27
+ RUN npm install -g mocha
28
+
29
+ # Install node modules
30
+ RUN npm cache clean --force && \
31
+ for i in 1 2 3; do \
32
+ npm ci && break || \
33
+ if [ $i -lt 3 ]; then \
34
+ sleep 15; \
35
+ else \
36
+ exit 1; \
37
+ fi; \
38
+ done
39
+
40
+ # Run the build command if necessary
41
+ RUN cd src/gui && npm run build && cd -
42
+
43
+ # Production stage
44
+ FROM node:23.9-alpine
45
+
46
+ # Set labels
47
+ LABEL repo="https://github.com/HeyPuter/puter"
48
+ LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
49
+ LABEL version="1.2.46-beta-1"
50
+
51
+ # Install git (required by Puter to check version)
52
+ RUN apk add --no-cache git
53
+
54
+ # Set up working directory
55
+ RUN mkdir -p /opt/puter/app
56
+ WORKDIR /opt/puter/app
57
+
58
+ # Copy built artifacts and necessary files from the build stage
59
+ COPY --from=build /app/src/gui/dist ./dist
60
+ COPY --from=build /app/node_modules ./node_modules
61
+ COPY . .
62
+
63
+ # Set permissions
64
+ RUN chown -R node:node /opt/puter/app
65
+ USER node
66
+
67
+ EXPOSE 4100
68
+
69
+ HEALTHCHECK --interval=30s --timeout=3s \
70
+ CMD wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
71
+
72
+ ENV NO_VAR_RUNTUME=1
73
+
74
+ # Attempt to fix `[email protected]` missing after build stage
75
+ # by doing a redundant `npm install` at this stage
76
+ RUN npm install
77
+
78
+ CMD ["npm", "start"]