-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
80 lines (60 loc) · 1.81 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
# ========================================
# Base image
# ========================================
FROM python:3.8.2-slim as base
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
RUN pip install pipenv
# ========================================
# Build dependencies stage
# ========================================
FROM base as build-deps
# Copy Pipfiles
COPY Pipfile Pipfile.lock ./
# Install Python dependencies
ARG DEV
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy $(if [ "$DEV" ]; then echo --dev; fi)
# ========================================
# Runtime stage
# ========================================
FROM base
LABEL org.opencontainers.image.source https://github.com/SBRG/lifelike
# Install curl for self healthchecks
RUN apt-get update && apt-get install -y curl && apt-get clean
# Copy Python virtual environment
COPY --from=build-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"
# Set user and working directory
WORKDIR /app
RUN useradd -m -d /app app
USER app
# Copy application code
COPY --chown=app . .
# ArangoDB configuration
ENV ARANGODB_HOST=''
ENV ARANGODB_PORT=''
ENV ARANGODB_AUTH=''
ENV ARANGODB_SCHEME=''
# Redis cache configuration
ENV REDIS_HOST=redis
ENV REDIS_PORT=6379
ENV REDIS_PASSWORD=password
ENV REDIS_DB=0
# Default TTL for cache
ENV CACHE_TTL=86400
# Optional Elastic APM configuration.
# To enable, at least ELASTIC_APM_SERVER_URL must be set
# Other available variables: https://www.elastic.co/guide/en/apm/agent/python/master/configuration.html
ENV ELASTIC_APM_SERVER_URL=
ENV ELASTIC_APM_SERVICE_NAME=statistical-enrichment
# Flask env [development, testing, production]
ENV FLASK_ENV=production
# Listen port
ENV PORT=5000
EXPOSE $PORT
# Healtcheck
HEALTHCHECK --start-period=15s \
CMD curl -f localhost:$PORT/healthz || exit 1
CMD bin/startup.sh