forked from elephant-track/elephant-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
81 lines (66 loc) · 2.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime
# Modified from https://github.com/tiangolo/uwsgi-nginx-flask-docker (Apache license)
LABEL maintainer="Ko Sugawara <[email protected]>"
# Install requirements
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
nginx \
redis-server \
supervisor \
ca-certificates \
curl \
gnupg \
gosu && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Python modules
COPY ./environment.yml /tmp/environment.yml
RUN sed -i '/.\/elephant-core/d' /tmp/environment.yml \
&& conda install -c conda-forge -y mamba \
&& mamba clean -qafy \
&& mamba env update -f /tmp/environment.yml \
&& mamba clean -qafy \
&& rm -rf /tmp/elephant-core \
&& rm /tmp/environment.yml
# Install and set up RabbbitMQ
COPY docker/install-rabbitmq.sh /tmp/install-rabbitmq.sh
RUN chmod +x /tmp/install-rabbitmq.sh && /tmp/install-rabbitmq.sh && rm /tmp/install-rabbitmq.sh
EXPOSE 5672
ENV RABBITMQ_USER user
ENV RABBITMQ_PASSWORD user
ENV RABBITMQ_PID_FILE /var/lib/rabbitmq/mnesia/rabbitmq.pid
COPY docker/rabbitmq.sh /rabbitmq.sh
RUN chmod +x /rabbitmq.sh
# Set up nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 443
RUN groupadd -r nginx && useradd -r -g nginx nginx
# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN pip install memory_profiler line_profiler
# Copy the base uWSGI ini file to enable default dynamic uwsgi process number
COPY docker/uwsgi.ini /etc/uwsgi/uwsgi.ini
# Custom Supervisord config
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY docker/start.sh /start.sh
RUN chmod +x /start.sh
# Make /app/* available to be imported by Python globally to better support several use cases like Alembic migrations.
ENV PYTHONPATH=/app
# Add scripts
COPY ./script /opt/elephant/script
# Add Flask app
COPY ./app /app
WORKDIR /app
# Copy the entrypoint
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
COPY ./elephant-core /tmp/elephant-core
RUN pip install -U /tmp/elephant-core && rm -rf /tmp/elephant-core
# Run the start script provided by the parent image tiangolo/uwsgi-nginx.
# It will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]