-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (42 loc) · 1.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
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Install system dependencies required for numpy/matplotlib
RUN apt-get update && apt-get install -y \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the current directory contents into the container at /app
COPY . /app
# Copy analysis scripts to root directory
COPY processing/data-analysis.py /app/data-analysis.py
COPY processing/data-processor.py /app/data-processor.py
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir \
apscheduler \
pandas \
numpy \
matplotlib \
seaborn
# Make port 5000 available to the world outside this container
EXPOSE 5000
# Define environment variables
ENV FLASK_APP=app.py
ENV DATA_DIR=/app/data
# Create necessary directories and set permissions
RUN mkdir -p /app/data \
&& mkdir -p /app/static/images/stats \
&& mkdir -p /app/results \
&& chmod -R 777 /app/static/images/stats \
&& chmod -R 777 /app/data \
&& chmod -R 777 /app/results
# Create a script to run both the stats updater and Gunicorn
RUN echo '#!/bin/bash\n\
python3 -c "from stats_updater import StatsUpdater; updater = StatsUpdater(); updater.start()" & \n\
gunicorn --bind 0.0.0.0:5000 app:app\n\
' > /app/start.sh \
&& chmod +x /app/start.sh
# Run the start script when the container launches
CMD ["/app/start.sh"]