Spaces:
Running
Running
fix commit latest
Browse files- Dockerfile +27 -15
Dockerfile
CHANGED
@@ -21,16 +21,8 @@ ENV HF_DATASETS_CACHE=/tmp/huggingface-cache
|
|
21 |
# Copy requirements từ project hiện tại
|
22 |
COPY requirements.txt .
|
23 |
|
24 |
-
#
|
25 |
-
RUN --mount=type=secret,id=BITBUCKET_APP_PW,mode=0444,required=true \
|
26 |
-
git clone https://vumichien:$(cat /run/secrets/BITBUCKET_APP_PW)@bitbucket.org/dtm-partners/meisai-check-ai.git && \
|
27 |
-
cd meisai-check-ai && \
|
28 |
-
git checkout chien_develop && \
|
29 |
-
cd ..
|
30 |
-
|
31 |
-
# Cài đặt dependencies
|
32 |
RUN pip install --no-cache-dir -r requirements.txt
|
33 |
-
RUN pip install --no-cache-dir -r meisai-check-ai/requirements.txt
|
34 |
|
35 |
# Copy code của API vào container
|
36 |
COPY . .
|
@@ -39,9 +31,6 @@ COPY . .
|
|
39 |
RUN mkdir -p /app/data
|
40 |
COPY ./data/* /app/data/
|
41 |
|
42 |
-
# Thêm đường dẫn meisai-check-ai vào PYTHONPATH
|
43 |
-
ENV PYTHONPATH="${PYTHONPATH}:/app/meisai-check-ai"
|
44 |
-
|
45 |
# Expose port
|
46 |
EXPOSE 7860
|
47 |
|
@@ -50,6 +39,29 @@ RUN useradd -m appuser
|
|
50 |
RUN chown -R appuser:appuser /app /tmp/matplotlib-cache /tmp/huggingface-cache
|
51 |
USER appuser
|
52 |
|
53 |
-
#
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Copy requirements từ project hiện tại
|
22 |
COPY requirements.txt .
|
23 |
|
24 |
+
# Cài đặt dependencies cho API
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
26 |
|
27 |
# Copy code của API vào container
|
28 |
COPY . .
|
|
|
31 |
RUN mkdir -p /app/data
|
32 |
COPY ./data/* /app/data/
|
33 |
|
|
|
|
|
|
|
34 |
# Expose port
|
35 |
EXPOSE 7860
|
36 |
|
|
|
39 |
RUN chown -R appuser:appuser /app /tmp/matplotlib-cache /tmp/huggingface-cache
|
40 |
USER appuser
|
41 |
|
42 |
+
# Tạo script để clone repository và chạy ứng dụng
|
43 |
+
RUN echo '#!/bin/bash \n\
|
44 |
+
# Clone hoặc pull repository mới nhất từ nhánh chien_develop \n\
|
45 |
+
if [ -d "/app/meisai-check-ai" ]; then \n\
|
46 |
+
cd /app/meisai-check-ai && \n\
|
47 |
+
git fetch && \n\
|
48 |
+
git checkout chien_develop && \n\
|
49 |
+
git pull \n\
|
50 |
+
else \n\
|
51 |
+
git clone https://vumichien:${BITBUCKET_APP_PW}@bitbucket.org/dtm-partners/meisai-check-ai.git && \n\
|
52 |
+
cd meisai-check-ai && \n\
|
53 |
+
git checkout chien_develop \n\
|
54 |
+
fi \n\
|
55 |
+
\n\
|
56 |
+
# Cài đặt dependencies của AI module \n\
|
57 |
+
pip install --no-cache-dir -r /app/meisai-check-ai/requirements.txt \n\
|
58 |
+
\n\
|
59 |
+
# Thêm đường dẫn meisai-check-ai vào PYTHONPATH \n\
|
60 |
+
export PYTHONPATH="${PYTHONPATH}:/app/meisai-check-ai" \n\
|
61 |
+
\n\
|
62 |
+
# Chạy ứng dụng với Uvicorn \n\
|
63 |
+
uvicorn main:app --host 0.0.0.0 --port 7860 \n\
|
64 |
+
' > /app/start.sh && chmod +x /app/start.sh
|
65 |
+
|
66 |
+
# Chạy script khi container khởi động
|
67 |
+
CMD ["/app/start.sh"]
|