Create Dockerfile
Browse files- Dockerfile +39 -0
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Ubuntu as the base image
|
| 2 |
+
FROM ubuntu:22.04
|
| 3 |
+
|
| 4 |
+
# Set environment variables to prevent prompts during installation
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
|
| 7 |
+
# Update and install required packages
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
python3 python3-pip python3-venv curl wget build-essential && \
|
| 10 |
+
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
|
| 11 |
+
apt-get install -y nodejs && \
|
| 12 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# Add a new user
|
| 15 |
+
RUN useradd -m -u 1000 user
|
| 16 |
+
USER user
|
| 17 |
+
|
| 18 |
+
# Set environment variables for the new user
|
| 19 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 20 |
+
|
| 21 |
+
# Set the working directory
|
| 22 |
+
WORKDIR /app
|
| 23 |
+
|
| 24 |
+
# Copy and install Python dependencies
|
| 25 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 26 |
+
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
| 27 |
+
|
| 28 |
+
# Copy application code
|
| 29 |
+
COPY --chown=user . /app
|
| 30 |
+
|
| 31 |
+
# Define the environment variable for the Node.js file URL
|
| 32 |
+
ARG NODE_JS_FILE
|
| 33 |
+
ENV NODE_JS_FILE=${NODE_JS_FILE}
|
| 34 |
+
|
| 35 |
+
# Download the Node.js file from the environment variable
|
| 36 |
+
RUN if [ -n "${NODE_JS_FILE}" ]; then wget -O /app/script.js "${NODE_JS_FILE}"; fi
|
| 37 |
+
|
| 38 |
+
# Default command to run the application
|
| 39 |
+
CMD ["/bin/bash", "-c", "node /app/script.js"]
|