Skip to content

Commit 1313d2f

Browse files
authored
Merge pull request #17 from p0bailey/dev
Dev
2 parents db2d053 + b71f162 commit 1313d2f

File tree

16 files changed

+2293
-102
lines changed

16 files changed

+2293
-102
lines changed

.dockerignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Version control
2+
.git
3+
.gitignore
4+
5+
# Documentation
6+
README.md
7+
*.md
8+
9+
# IDE and editor files
10+
.vscode/
11+
.idea/
12+
*.swp
13+
*.swo
14+
*~
15+
16+
# OS generated files
17+
.DS_Store
18+
.DS_Store?
19+
._*
20+
.Spotlight-V100
21+
.Trashes
22+
ehthumbs.db
23+
Thumbs.db
24+
25+
# Python
26+
__pycache__/
27+
*.py[cod]
28+
*$py.class
29+
*.so
30+
.Python
31+
build/
32+
develop-eggs/
33+
dist/
34+
downloads/
35+
eggs/
36+
.eggs/
37+
lib/
38+
lib64/
39+
parts/
40+
sdist/
41+
var/
42+
wheels/
43+
*.egg-info/
44+
.installed.cfg
45+
*.egg
46+
47+
# Virtual environments
48+
venv/
49+
env/
50+
ENV/
51+
52+
# Testing
53+
.pytest_cache/
54+
.coverage
55+
htmlcov/
56+
.tox/
57+
58+
# Logs
59+
*.log
60+
61+
# Temporary files
62+
*.tmp
63+
*.temp

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Trivy security scanner files
2+
.trivy/
3+
trivy.yaml
4+
reports/

.img/1.png

642 KB
Loading

.img/2.png

248 KB
Loading

.trivyignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Trivy ignore file
2+
# Format: https://aquasecurity.github.io/trivy/latest/docs/vulnerability/examples/filter/
3+
4+
# Ignore test files and development dependencies
5+
**/test/**
6+
**/tests/**
7+
**/*test*
8+
**/node_modules/**
9+
**/.git/**
10+
**/.pytest_cache/**
11+
**/__pycache__/**
12+
13+
# Ignore specific low-impact vulnerabilities (example)
14+
# CVE-2023-xxxxx
15+
16+
# Ignore base image vulnerabilities that cannot be fixed
17+
# debian:bookworm-slim known issues
18+
# CVE-2024-xxxxx
19+
20+
# Ignore supervisor-related root user requirement
21+
AVD-DS-0002
22+
23+
# Ignore documentation and example files
24+
**/docs/**
25+
**/examples/**
26+
**/*.md
27+
**/*.txt
28+
LICENSE
29+
README*
30+
31+
# Ignore static assets
32+
**/static/**
33+
**/assets/**
34+
**/*.css
35+
**/*.js
36+
**/*.png
37+
**/*.jpg
38+
**/*.gif

Dockerfile

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
1-
FROM debian:stretch-slim
1+
FROM debian:bookworm-slim
22

3-
MAINTAINER Phillip Bailey <[email protected]>
3+
LABEL maintainer="Phillip Bailey"
44

5-
ENV DEBIAN_FRONTEND noninteractive
5+
ENV DEBIAN_FRONTEND=noninteractive
66

7-
RUN apt-get update && apt-get dist-upgrade && apt-get install -y \
8-
python-pip python-dev uwsgi-plugin-python \
9-
nginx supervisor
7+
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y --no-install-recommends \
8+
python3-dev build-essential gcc \
9+
nginx supervisor curl ca-certificates \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Install uv
14+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
15+
16+
# Create non-root user and add to www-data group
17+
RUN groupadd -r appuser && useradd -r -g appuser appuser \
18+
&& usermod -a -G www-data appuser
1019

1120
COPY nginx/flask.conf /etc/nginx/sites-available/
1221
COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
1322

1423
COPY app /var/www/app
1524

16-
RUN mkdir -p /var/log/nginx/app /var/log/uwsgi/app /var/log/supervisor \
25+
RUN mkdir -p /var/log/nginx/app /var/log/supervisor \
1726
&& rm /etc/nginx/sites-enabled/default \
1827
&& ln -s /etc/nginx/sites-available/flask.conf /etc/nginx/sites-enabled/flask.conf \
1928
&& echo "daemon off;" >> /etc/nginx/nginx.conf \
20-
&& pip install -r /var/www/app/requirements.txt \
21-
&& chown -R www-data:www-data /var/www/app \
22-
&& chown -R www-data:www-data /var/log
29+
&& sed -i 's|pid /run/nginx.pid;|pid /var/run/nginx.pid;|' /etc/nginx/nginx.conf \
30+
&& uv pip install --system --no-cache --break-system-packages -r /var/www/app/requirements.txt \
31+
&& chown -R appuser:appuser /var/www/app \
32+
&& chown -R appuser:appuser /var/log \
33+
&& chown -R appuser:appuser /var/run
34+
35+
EXPOSE 8080
2336

37+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
38+
CMD curl -f http://localhost:8080/ || exit 1
2439

25-
CMD ["/usr/bin/supervisord"]
40+
# Run as non-root user for security (nginx can now bind to non-privileged port 8080)
41+
USER appuser
42+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

0 commit comments

Comments
 (0)