-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
Dockerfile
68 lines (54 loc) · 2.48 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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 Chrome WebDriver
# RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
# mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
# unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# rm /tmp/chromedriver_linux64.zip && \
# chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
# ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/google-chrome-stable /usr/local/bin/google-chrome
# Install Poetry and dependencies
RUN pip install poetry
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock* ./
RUN poetry lock
RUN poetry install --no-root
# 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 Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
# Check if .env exists and run dos2unix on it, otherwise skip
RUN if [ -f /blt/.env ]; then dos2unix /blt/.env; fi
RUN chmod +x /blt/entrypoint.sh
ENTRYPOINT ["/blt/entrypoint.sh"]
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]