ABAO77 commited on
Commit
0448eaf
·
verified ·
1 Parent(s): 150102c

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +61 -0
Dockerfile ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Cập nhật package list và cài đặt các dependencies cần thiết
4
+ RUN apt-get update && \
5
+ apt-get install -y --no-install-recommends \
6
+ # Basic system tools
7
+ gcc \
8
+ g++ \
9
+ clang \
10
+ clang++ \
11
+ make \
12
+ git \
13
+ wget \
14
+ curl \
15
+ # Libraries for various functionalities
16
+ libglib2.0-0 \
17
+ libsm6 \
18
+ libxext6 \
19
+ libxrender-dev \
20
+ # Java runtime and compiler
21
+ openjdk-17-jdk \
22
+ openjdk-17-jre \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Set JAVA_HOME environment variable
26
+ ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
27
+ ENV PATH="$JAVA_HOME/bin:$PATH"
28
+
29
+ # Verify installations
30
+ RUN python3 --version && \
31
+ gcc --version && \
32
+ g++ --version && \
33
+ java -version && \
34
+ javac -version
35
+
36
+ # Create non-root user
37
+ RUN useradd -m -u 1000 user
38
+ USER user
39
+ ENV PATH="/home/user/.local/bin:$PATH"
40
+ WORKDIR /app
41
+
42
+ # Copy requirements and install Python dependencies
43
+ COPY --chown=user ./requirements.txt requirements.txt
44
+ RUN pip install --no-cache-dir --upgrade pip && \
45
+ pip install --no-cache-dir --upgrade -r requirements.txt
46
+
47
+ # Copy application code
48
+ COPY --chown=user . /app
49
+
50
+ # Create temporary directory for code execution (with proper permissions)
51
+ RUN mkdir -p /tmp/code_workspace && chmod 755 /tmp/code_workspace
52
+
53
+ # Expose port
54
+ EXPOSE 7860
55
+
56
+ # Health check
57
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
58
+ CMD curl -f http://localhost:7860/health || exit 1
59
+
60
+ # Start command
61
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]