-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
69 lines (52 loc) · 1.55 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
###########
# BUILDER #
###########
# Python Version
ARG PYTHON_VERSION=3.7
# Pull the official base image
FROM python:${PYTHON_VERSION}-alpine AS base
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONBUFFERED 1
ENV BUILD_DIR /usr/src/stratum
# Install system libraries for building dependencies
RUN apk update
RUN apk add build-base gcc g++
# Install application specific dependencies
RUN mkdir -p $BUILD_DIR/wheels && mkdir -p $BUILD_DIR/bin
COPY requirements.txt $BUILD_DIR
RUN pip install --upgrade pip
RUN pip wheel --wheel-dir $BUILD_DIR/wheels -r $BUILD_DIR/requirements.txt
#########
# FINAL #
#########
# Pull the official base image
FROM python:${PYTHON_VERSION}-alpine
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONBUFFERED 1
ENV BUILD_DIR /usr/src/stratum
ENV PRJ_DIR /opt/kryotos
# Install system libraries for running dependencies
RUN apk update
RUN apk add g++
# Create application user
RUN addgroup --system kryptos && adduser --disabled-password --system --no-create-home --ingroup kryptos kryptos
# Copy compiled files from base
COPY --from=base $BUILD_DIR/wheels /opt/wheels
COPY --from=base $BUILD_DIR/requirements.txt /opt
COPY --from=base $BUILD_DIR/bin /usr/local/bin
# Install application specific dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache /opt/wheels/*
RUN rm -rf /opt/wheels
# Copy project
COPY . $PRJ_DIR
# Fix permissions
RUN chown -R kryptos:kryptos $PRJ_DIR
# Change the user to kryptos
USER kryptos
# Update work directory
WORKDIR $PRJ_DIR
# Run the sh command
CMD ["sh"]