Dockerfile 1.71 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
# set the base image. default is python
ARG base=python
# set the tag (e.g. latest, 3.8, 3.7 : for python)
BorjaEst's avatar
BorjaEst committed
14
ARG tag=3.6-slim
15

BorjaEst's avatar
BorjaEst committed
16
# Base image, e.g. python:3.6-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=master
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
# 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 \
36
37
        gcc \
        g++ \
38
39
40
41
42
43
44
45
        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:
BorjaEst's avatar
BorjaEst committed
46
RUN git clone --depth 1 -b ${branch} https://git.scc.kit.edu/synergy.o3as/o3skim.git app && \
47
48
49
# Install python application
    cd app && \
    pip3 install --no-cache-dir -e . && \
BorjaEst's avatar
BorjaEst committed
50
    pip3 install --no-cache-dir tox && \
51
52
53
54
55
56
57
# Clean up
    rm -rf /root/.cache/pip/* && \
    rm -rf /tmp/*
WORKDIR /app

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

# Start default script
63
ENTRYPOINT [ "main" ]
64
CMD [ "--verbosity ERROR" ]
65