saq1b commited on
Commit
834afd7
·
verified ·
1 Parent(s): 234fccf

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -20
Dockerfile CHANGED
@@ -1,36 +1,47 @@
1
- # Use an official Node.js runtime as a parent image
2
- FROM node:21
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- # Install Python
8
- RUN apt-get update && apt-get install -y python3 python3-pip
9
 
10
- # Copy package.json
11
- COPY package.json ./
12
 
13
  # Install frontend dependencies
14
  RUN npm install
15
 
16
- # Copy the rest of the application code
17
- COPY . .
 
 
18
 
19
- # Install backend dependencies
20
- RUN pip3 install --no-cache-dir -r requirements.txt
21
 
22
  # Build the Next.js app
23
  RUN npm run build
24
 
25
- # Make port 8000 available to the world outside this container
26
- EXPOSE 8000
27
-
28
  # Set execute permissions for the start script
29
  RUN chmod +x start.sh
30
 
31
- # Use a non-root user
32
- RUN useradd -m appuser
33
- USER appuser
34
-
35
- # Run the script when the container launches
36
  CMD ["./start.sh"]
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:latest
3
 
4
+ # Set environment variable to avoid buffering issues
5
+ ENV PYTHONUNBUFFERED 1
6
+
7
+ # Make port 8000 available to the world outside this container
8
+ EXPOSE 8000
9
+
10
+ # Update apt and install curl
11
+ RUN apt update && apt install -y curl
12
+
13
+ # Install Node.js from the NodeSource repository
14
+ RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - && \
15
+ apt install -y nodejs
16
+
17
+ # Add a non-root user with specific UID and switch to that user
18
+ RUN useradd -m -u 1000 appuser
19
+ USER appuser
20
+ ENV HOME=/home/appuser \
21
+ PATH=/home/appuser/.local/bin:$PATH
22
 
23
+ # Set the working directory in the container
24
+ WORKDIR $HOME/app
25
 
26
+ # Copy package.json and package-lock.json to the container as appuser
27
+ COPY --chown=appuser package*.json ./
28
 
29
  # Install frontend dependencies
30
  RUN npm install
31
 
32
+ # Copy Python requirements file and install backend dependencies
33
+ COPY --chown=appuser requirements.txt ./
34
+ RUN pip install --upgrade pip && \
35
+ pip install --no-cache-dir -r requirements.txt
36
 
37
+ # Copy the rest of the application code as appuser
38
+ COPY --chown=appuser . .
39
 
40
  # Build the Next.js app
41
  RUN npm run build
42
 
 
 
 
43
  # Set execute permissions for the start script
44
  RUN chmod +x start.sh
45
 
46
+ # Set the default command to run the start script
 
 
 
 
47
  CMD ["./start.sh"]