puter/Dockerfile

79 lines
1.9 KiB
Docker
Raw Normal View History

2024-04-16 06:58:28 +08:00
# /!\ NOTICE /!\
# Many of the developers DO NOT USE the Dockerfile or image.
# While we do test new changes to Docker configuration, it's
# possible that future changes to the repo might break it.
# When changing this file, please try to make it as resiliant
# to such changes as possible; developers shouldn't need to
# worry about Docker unless the build/run process changes.
# Build stage
2025-01-09 01:11:43 +08:00
FROM node:22-alpine AS build
# Install build dependencies
RUN apk add --no-cache git python3 make g++ \
&& ln -sf /usr/bin/python3 /usr/bin/python
# Set up working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
2024-04-16 06:58:28 +08:00
# Copy the source files
COPY . .
2024-07-19 04:33:02 +08:00
# Install mocha
RUN npm install -g mocha
# Install node modules
RUN npm cache clean --force && \
for i in 1 2 3; do \
npm ci && break || \
if [ $i -lt 3 ]; then \
sleep 15; \
else \
exit 1; \
fi; \
done
# Run the build command if necessary
2024-07-08 12:31:02 +08:00
RUN cd src/gui && npm run build && cd -
# Production stage
2025-01-09 01:20:05 +08:00
FROM node:22-alpine
2024-03-07 02:52:51 +08:00
# Set labels
LABEL repo="https://github.com/HeyPuter/puter"
LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
2024-03-31 17:18:03 +08:00
LABEL version="1.2.46-beta-1"
2024-03-07 02:52:51 +08:00
2024-03-31 17:18:03 +08:00
# Install git (required by Puter to check version)
RUN apk add --no-cache git
# Set up working directory
2024-03-07 02:52:51 +08:00
RUN mkdir -p /opt/puter/app
WORKDIR /opt/puter/app
# Copy built artifacts and necessary files from the build stage
2024-07-08 12:31:02 +08:00
COPY --from=build /app/src/gui/dist ./dist
COPY --from=build /app/node_modules ./node_modules
2024-04-16 06:58:28 +08:00
COPY . .
2024-03-07 02:52:51 +08:00
# Set permissions
RUN chown -R node:node /opt/puter/app
USER node
2024-03-31 17:18:03 +08:00
EXPOSE 4100
2024-03-07 02:52:51 +08:00
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
2024-03-07 02:52:51 +08:00
2024-04-16 08:47:27 +08:00
ENV NO_VAR_RUNTUME=1
# Attempt to fix `lru-cache@11.0.2` missing after build stage
# by doing a redundant `npm install` at this stage
RUN npm install
2024-04-16 06:58:28 +08:00
CMD ["npm", "start"]