-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (65 loc) · 2.5 KB
/
Copy pathDockerfile
File metadata and controls
78 lines (65 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
### BUILDER STAGE ###
FROM python:3.11-slim AS builder
WORKDIR /app
# CPU-only paketleri kullanmak için çevresel değişkenler
ENV PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
NVIDIA_VISIBLE_DEVICES="" \
CUDA_VISIBLE_DEVICES="" \
NO_CUDA=1
# Derleme için gerekli sistem paketlerinin yüklenmesi
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# requirements.txt dosyasını düzenleme ve paketleri kurma
COPY config/requirements.txt /app/
RUN pip install --upgrade pip && \
sed -i '/eth-brownie/d' /app/requirements.txt && \
# CPU-only torch paketleri için özel index-url kullanılması
pip wheel --no-cache-dir --wheel-dir /app/wheels \
-f https://download.pytorch.org/whl/torch_stable.html \
-r requirements.txt
### FINAL STAGE ###
FROM python:3.11-slim
WORKDIR /app
# CPU-only çevresel değişkenler
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
NVIDIA_VISIBLE_DEVICES="" \
CUDA_VISIBLE_DEVICES="" \
NO_CUDA=1
# Sadece gerekli sistem paketlerinin yüklenmesi
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
&& rm -rf /var/lib/apt/lists/*
# İlk aşamadaki oluşturulan wheel'leri kopyalayarak hızlı kurulum
COPY --from=builder /app/wheels /wheels
COPY config/requirements.txt /app/
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir /wheels/* -f https://download.pytorch.org/whl/torch_stable.html || \
(echo "Wheel paketleriyle kurulum sırasında hatalar oluştu, doğrudan pip kullanılıyor" && \
pip install --no-cache-dir -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html)
# Entrypoint betiğinin kopyalanması ve çalıştırma izni verilmesi
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Sadece gerekli dosyaları kopyala
COPY main.py .
COPY core ./core/
COPY modules ./modules/
COPY utils ./utils/
COPY scripts ./scripts/
COPY templates ./templates/
COPY config ./config/
COPY public ./public/
# Uygulama çalışacak kullanıcıyı oluşturma (güvenlik için)
RUN useradd -m securitynexus
RUN mkdir -p /app/reports /app/history && \
chown -R securitynexus:securitynexus /app
# Entrypoint ayarı
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["python", "main.py"]