Dockerfile 1.7 KB
Newer Older
1
# Dockerfile has three Arguments: base, tag, branch
2
# base - base image (default: python)
3
# tag - tag for base mage (default: stable-slim)
4
# branch - user repository branch to clone (default: python)
5
6
7
8
9
10
#
# To build the image:
# $ docker build -t <dockerhub_user>/<dockerhub_repo> --build-arg arg=value .
# or using default args:
# $ docker build -t <dockerhub_user>/<dockerhub_repo> .

11
12
13
14
# set the base image. default is python
ARG base=python
# set the tag (e.g. latest, 3.8, 3.7 : for python)
ARG tag=3.8-slim
15

16
# Base image, e.g. python:3.8-slim
17
18
FROM ${base}:${tag}

19
LABEL maintainer='B.Esteban, T.Kerzenmacher, V.Kozlov (KIT)'
20
21

# What branch to clone (!)
22
ARG branch=python
23
24

# Which user and group to use 
BorjaEst's avatar
BorjaEst committed
25
ARG user=application
26
27
ARG group=standard

BorjaEst's avatar
BorjaEst committed
28
29
30
# Set environments
ENV LANG C.UTF-8

31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Install system updates and tools
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
# Install system updates and tools
        ca-certificates \
        git && \
# Clean up & back to dialog front end
    apt-get autoremove -y && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog

# Install user app:
RUN git clone --depth 1 -b ${branch} https://github.com/BorjaEst/cicd.git app && \
45
46
47
# Install python application
    cd app && \
    pip3 install --no-cache-dir -e . && \
BorjaEst's avatar
BorjaEst committed
48
    pip3 install --no-cache-dir tox && \
49
50
51
52
53
54
55
56
57
58
59
# Clean up
    rm -rf /root/.cache/pip/* && \
    rm -rf /tmp/*
WORKDIR /app

# Ports to expose
EXPOSE 8443
EXPOSE 8080

# Change user context and drop root privileges
RUN groupadd -r ${group} && \
BorjaEst's avatar
BorjaEst committed
60
61
    useradd --no-log-init -r -d /app -g ${group} ${user} && \
    chown -R ${user} . 
62
63
64
USER ${user}

# Start default script
65
66
ENTRYPOINT [ "main" ]
CMD [ "-v 1" ]
67