ci: add ansible and CICD deployment
Push -> develop / Build Docker images (push) Successful in 14s
Push -> develop / Deploy (push) Successful in 19s
Push -> develop / Notify on result (push) Successful in 0s

This commit is contained in:
sangnn
2026-06-23 07:15:42 +00:00
parent a6d74d9316
commit 6a49eb29c8
24 changed files with 1078 additions and 31 deletions
+17 -5
View File
@@ -19,19 +19,31 @@ COPY requirements/base.txt requirements/base.txt
COPY requirements/production.txt requirements/production.txt
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip wheel && \
# Upgrade build tooling too: clears CVE-2026-24049 (wheel) and CVE-2026-23949 (jaraco.context)
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements/production.txt
# Production stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
# apt-get upgrade pulls patched openssl/openssh/etc. so the image isn't pinned to
# whatever was current when the base layer was published.
# curl intentionally omitted: it was only used by HEALTHCHECK (now a stdlib Python
# check), and dropping it removes libcurl4t64 + libssh2 and their unfixed CVEs.
# NOTE: openssh-client retained for SSH CA workflows; drop it too if nothing shells
# out to ssh/scp (sshkey-tools signing is pure Python).
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
libpq5 \
curl \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
# Patch the base image's system-level build tooling that Trivy flags in
# /usr/local site-packages: wheel (CVE-2026-24049) and the jaraco.context
# (CVE-2026-23949) vendored by setuptools. Runs against system pip before the
# venv takes over PATH below.
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Create non-root user
RUN groupadd --gid 1000 appgroup && \
useradd --uid 1000 --gid appgroup --shell /bin/bash --create-home appuser
@@ -53,9 +65,9 @@ USER appuser
# Expose port
EXPOSE 5000
# Health check
# Health check (stdlib urllib — avoids shipping curl)
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:5000/api/health || exit 1
CMD ["python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:5000/api/health', timeout=5).getcode()==200 else 1)"]
# Run gunicorn with gevent workers
CMD ["gunicorn", "--bind", "0.0.0.0:5000", \