forked from OWASP-BLT/BLT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (36 loc) · 1.32 KB
/
Dockerfile
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
# Stage 1: Build stage
FROM python:3.11.2 AS builder
ENV PYTHONUNBUFFERED 1
WORKDIR /blt
# Install system dependencies
RUN apt-get update && \
apt-get install -y postgresql-client libpq-dev \
libmemcached11 libmemcachedutil2 libmemcached-dev libz-dev \
dos2unix && \
rm -rf /var/lib/apt/lists/*
# Install Poetry and dependencies
RUN pip install poetry
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock* ./
RUN poetry install
# Install additional Python packages
RUN pip install opentelemetry-api opentelemetry-instrumentation
# Stage 2: Runtime stage
FROM python:3.11.2-slim
ENV PYTHONUNBUFFERED 1
WORKDIR /blt
# Copy only necessary files from builder stage
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Install runtime system dependencies
RUN apt-get update && \
apt-get install -y postgresql-client libpq-dev \
libmemcached11 libmemcachedutil2 dos2unix && \
rm -rf /var/lib/apt/lists/*
# Copy application code
COPY . /blt
# Convert line endings and set permissions
RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
RUN chmod +x /blt/entrypoint.sh
ENTRYPOINT ["/blt/entrypoint.sh"]
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]