Skip to content

Commit a95f01a

Browse files
committed
Updated Dockerfile for improved security and maintainability
1 parent d6d676a commit a95f01a

2 files changed

Lines changed: 80 additions & 12 deletions

File tree

.dockerignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Version control
2+
.git
3+
.github
4+
.gitignore
5+
6+
# IDE and editor files
7+
.idea
8+
.vscode
9+
*.swp
10+
*.swo
11+
*~
12+
13+
# Python artifacts
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
*.so
18+
.Python
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
wheels/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
35+
# Virtual environments
36+
myenv/
37+
venv/
38+
ENV/
39+
env/
40+
.env
41+
42+
# Logs and databases
43+
logs/
44+
*.log
45+
*.sqlite3
46+
*.db
47+
48+
# OS specific files
49+
.DS_Store
50+
Thumbs.db
51+
52+
# Documentation and non-essential files
53+
docs/
54+
images/
55+
demo/
56+
*.md
57+
!README.md
58+
!CONTRIBUTING.md
59+
60+
# Other project-specific files
61+
untitled/
62+
iunera/
63+
64+
# Keep necessary files
65+
!code/
66+
!static/
67+
68+
# Remove local configuration from code directory
69+
code/.env
70+
code/logs/

Dockerfile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Stage 1: Build stage
22
FROM python:3.13-slim AS builder
33

4-
WORKDIR /app
5-
6-
# Copy requirements file
7-
COPY code/requirements.txt .
8-
9-
# Install build dependencies and Python packages
4+
# Install build dependencies
105
RUN apt-get update && \
116
apt-get install -y --no-install-recommends gcc python3-dev && \
127
pip install --no-cache-dir --upgrade pip && \
13-
pip install --no-cache-dir -r requirements.txt && \
148
apt-get clean && \
159
rm -rf /var/lib/apt/lists/*
1610

11+
WORKDIR /app
12+
13+
# Copy requirements file
14+
COPY code/requirements.txt .
15+
16+
# Install Python packages
17+
RUN pip install --no-cache-dir -r requirements.txt
18+
1719
# Stage 2: Runtime stage
1820
FROM python:3.13-slim
1921

@@ -37,11 +39,7 @@ USER nlweb
3739
COPY code/ /app/
3840
COPY static/ /app/static/
3941

40-
# Remove local logs and .env file
41-
RUN rm -r code/logs/* || true && \
42-
rm -r code/.env || true
43-
44-
# Copy installed packages from builder stage
42+
# Copy installed packages from builder stage
4543
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
4644
COPY --from=builder /usr/local/bin /usr/local/bin
4745

0 commit comments

Comments
 (0)