-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathserver_dockerfile
46 lines (34 loc) · 1.52 KB
/
server_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
# syntax=docker/dockerfile:experimental
FROM python:3.10 as base
SHELL ["/bin/bash", "--login", "-c"]
# Useful for installing deps from git, preventing big downloads and bandwith quotas
ENV GIT_LFS_SKIP_SMUDGE=1
# Install system dependencies
RUN apt update && apt install -y gnupg curl tree mdbtools && apt clean
# Install MongoDB tools in the official way
WORKDIR /opt
RUN wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.0.deb && apt install ./mongodb-database-tools-*-100.9.0.deb
FROM base as app
# Copy all server code into workdir
WORKDIR /app
RUN pip install pipenv
COPY pydatalab/Pipfile pydatalab/Pipfile.lock ./
# Create development image using flask's dev server with hot-reload
FROM app as development
RUN --mount=type=cache,target=/root/.cache/pip pipenv sync
ENV FLASK_APP "pydatalab.main:create_app()"
ENV FLASK_ENV "development"
ENV PORT=5001
CMD ["/bin/bash", "-c", "pipenv run flask run --port ${PORT} --host 0.0.0.0"]
# Create production image using gunicorn and minimal dependencies
FROM app as production
RUN --mount=type=cache,target=/root/.cache/pip pipenv sync
RUN [ "pipenv", "run", "pip", "install", "gunicorn" ]
COPY ./pydatalab/ ./
# This will define the number of gunicorn workers
ARG WEB_CONCURRENCY=4
ENV WEB_CONCURRENCY=${WEB_CONCURRENCY}
ARG PORT=5001
EXPOSE ${PORT}
ENV PORT=${PORT}
CMD ["/bin/bash", "-c", "pipenv run gunicorn --preload -w ${WEB_CONCURRENCY} --error-logfile /logs/pydatalab_error.log --access-logfile - -b 0.0.0.0:${PORT} 'pydatalab.main:create_app()'"]