Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chatbot_canifa_test_conservation_tools
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
chatbot_canifa_test_conservation_tools
Commits
2ef3ac05
Commit
2ef3ac05
authored
Jan 12, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update Dockerfile, entrypoint.sh, Makefile - optimize production build
parent
5748e55c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
44 deletions
+17
-44
Dockerfile.dev
backend/Dockerfile.dev
+2
-3
Dockerfile.prod
backend/Dockerfile.prod
+11
-31
Dockerfile.stage
backend/Dockerfile.stage
+1
-2
Makefile
backend/Makefile
+1
-2
entrypoint.sh
backend/entrypoint.sh
+2
-6
No files found.
backend/Dockerfile.dev
View file @
2ef3ac05
...
...
@@ -15,9 +15,8 @@ ENV ENV=development
# Copy requirements.txt trước để tận dụng Docker cache
COPY requirements.txt .
# Cài đặt thư viện Python (với cache mount cho tốc độ)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
# Cài đặt thư viện Python (Docker layer cache)
RUN pip install -r requirements.txt
# Copy toàn bộ source code vào image
COPY . .
...
...
backend/Dockerfile.prod
View file @
2ef3ac05
# ============================================================
# DOCKERFILE.PROD - Production (Multi-Worker Gunicorn)
# ============================================================
# Multi-stage build để optimize dung lượng image
FROM python:3.11-slim AS builder
WORKDIR /app
# Copy requirements.txt
COPY requirements.txt .
# Install dependencies to a local directory (with cache mount for speed)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --user -r requirements.txt
# ============================================================
# Final stage - Production image (tối giản)
# Lấy Python 3.11 slim (ít file, nhẹ)
FROM python:3.11-slim
# Thư mục làm việc
WORKDIR /app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV ENV=production
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
# Copy
Python packages từ builder st
age
COPY
--from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
# Copy
requirements rồi cài pack
age
COPY
requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy
source
code
# Copy code
COPY . .
# Copy entrypoint script
# Copy entrypoint script
(nếu có)
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
#
Expose
port 5000
#
Mở
port 5000
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:5000/health')" || exit 1
ENTRYPOINT ["/app/entrypoint.sh"]
# Chạy server
CMD ["/app/entrypoint.sh"]
\ No newline at end of file
backend/Dockerfile.stage
View file @
2ef3ac05
...
...
@@ -16,8 +16,7 @@ ENV ENV=development
COPY requirements.txt .
# Cài đặt thư viện Python (với cache mount)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
RUN pip install -r requirements.txt
# Copy toàn bộ source code vào image
COPY . .
...
...
backend/Makefile
View file @
2ef3ac05
...
...
@@ -12,8 +12,7 @@ restart:
docker-compose restart backend
logs
:
sudo
docker logs
-f
canifa_backend
sudo
ps
:
docker-compose ps
...
...
backend/entrypoint.sh
View file @
2ef3ac05
#!/bin/bash
# Lấy số CPU cores
NUM_CORES
=
$(
nproc
)
WORKERS
=
$((
2
*
NUM_CORES
+
1
))
echo
"🔧 [STARTUP]
Detected
CPU cores:
$NUM_CORES
"
echo
"🔧 [STARTUP] CPU cores:
$NUM_CORES
"
echo
"🔧 [STARTUP] Gunicorn workers:
$WORKERS
"
echo
"🔧 [STARTUP] Environment:
${
ENV
:-
production
}
"
# Chạy Gunicorn với số workers tính toán được
exec
gunicorn
\
server:app
\
--workers
"
$WORKERS
"
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment