forked from v3rbalgit/grindhousebot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (44 loc) · 1.44 KB
/
Dockerfile
File metadata and controls
58 lines (44 loc) · 1.44 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
FROM python:3.12.8-slim AS builder
# Install build dependencies and git
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Create and activate virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir git+https://github.com/twopirllc/pandas-ta.git@development
FROM python:3.12.8-slim
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
# Create non-root user
RUN useradd -r -s /bin/false appuser
# Create and set permissions for numba cache directory
RUN mkdir -p /tmp/numba_cache && \
chown -R appuser:appuser /tmp/numba_cache
# Set working directory
WORKDIR /app
# Copy application code
COPY . .
# Set proper permissions
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Add signal handling wrapper script
RUN echo '#!/bin/sh\n\
trap "exit 0" TERM INT\n\
python main.py & PID=$!\n\
wait $PID\n\
trap - TERM INT\n\
wait $PID\n\
EXIT_STATUS=$?' > /app/docker-entrypoint.sh \
&& chmod +x /app/docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]