File size: 1,398 Bytes
5da9a80 5829af2 1737bf8 5829af2 5da9a80 5829af2 5da9a80 5829af2 b3b1b84 5829af2 b3b1b84 5829af2 d04a21f 68c1327 5da9a80 5829af2 | 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 | # Use Ubuntu as the base image
FROM ubuntu:22.04
# Set environment variables to prevent prompts during installation
ENV DEBIAN_FRONTEND=noninteractive
# Update and install required packages
RUN apt-get update && apt-get install -y \
python3 python3-pip python3-venv curl wget build-essential && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Add a new user
RUN useradd -m -u 1000 user
USER user
# Set environment variables for the new user
ENV PATH="/home/user/.local/bin:$PATH"
# Set the working directory
WORKDIR /app
# Define arguments for the Node.js file and JSON file
ARG NODE_JS_FILE
ARG JSON_FILE
# Define environment variables for the files
ENV NODE_JS_FILE=${NODE_JS_FILE}
ENV JSON_FILE=${JSON_FILE}
# Copy application code
COPY --chown=user . /app
# Download the Node.js file if specified
RUN if [ -n "${NODE_JS_FILE}" ]; then wget -O /app/script.js "${NODE_JS_FILE}"; fi
# Download the package.json file if specified
RUN if [ -n "${JSON_FILE}" ]; then wget -O /app/package.json "${JSON_FILE}"; fi
# Install Node.js dependencies if package.json exists
RUN if [ -f "/app/package.json" ]; then npm install; fi
# Install global npm dependencies without sudo
# RUN npm install -g ws
EXPOSE 7860
# Default command to run the application
CMD ["node", "/app/script.js"]
|