joe4ai commited on
Commit
2c597c6
·
verified ·
1 Parent(s): 9fa5d00

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +46 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim-buster
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ curl \
11
+ software-properties-common \
12
+ git \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Copy the current directory contents into the container at /app
16
+ COPY . /app
17
+
18
+ # Create a virtual environment
19
+ RUN python -m venv venv
20
+
21
+ # Activate virtual environment and upgrade pip
22
+ RUN . venv/bin/activate && \
23
+ pip install --upgrade pip
24
+
25
+ # Install Python dependencies
26
+ RUN . venv/bin/activate && \
27
+ pip install -r requirements.txt
28
+
29
+ # Expose the port the app runs on
30
+ EXPOSE 8000
31
+
32
+ # Set environment variables
33
+ # Use ARG for build-time variables that can be overridden
34
+ ARG TRACE
35
+ ENV TRACE=${TRACE}
36
+
37
+ # Create a non-root user for security
38
+ RUN useradd -m appuser
39
+ USER appuser
40
+
41
+ # Health check to ensure the application is running
42
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
43
+ CMD curl -f http://localhost:8000 || exit 1
44
+
45
+ # Command to run the application
46
+ CMD ["/bin/bash", "-c", ". venv/bin/activate && python main.py"]