Dockerfile 1.38 KB
Newer Older
Mattia Bergagio's avatar
Mattia Bergagio committed
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
FROM python:3.9.16-slim-bullseye

ENV TZ='Europe/Rome'
ENV BASE_FOLDER='/CTRLR'
ENV LOGS_FOLDER='/LOGS'
ENV APP_USER='devuser'

ARG GIT_NAME
ARG GIT_TOKEN

RUN \
  apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
    tzdata \
    # TODO Other packets common to all images go in here
    curl \
    iputils-ping \
    git \
  && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* && \
  ln -snf "/usr/share/zoneinfo/$TZ" '/etc/localtime' && \
  echo "$TZ" > '/etc/timezone'

RUN useradd -m "$APP_USER" && \
  mkdir -p "$BASE_FOLDER" && \
  chown -R "${APP_USER}:${APP_USER}" "$BASE_FOLDER" && \
  mkdir -p "$LOGS_FOLDER" && \
  chown -R "${APP_USER}:${APP_USER}" "$LOGS_FOLDER"

USER "$APP_USER"
WORKDIR "$BASE_FOLDER"

ENV PATH="${PATH}:/root/.local/bin:/home/${APP_USER}/.local/bin"
ENV PYTHONPATH="${PYTHONPATH}:${BASE_FOLDER}"

COPY --chown="${APP_USER}:${APP_USER}"  /controller/requirements.txt ./requirements.txt
RUN \
  python3 -m pip install --upgrade pip && \
  python3 -m pip install --no-cache-dir -r requirements.txt

WORKDIR "$BASE_FOLDER"/src
Mattia Bergagio's avatar
Mattia Bergagio committed
43
RUN git clone https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/common_module.git
Mattia Bergagio's avatar
Mattia Bergagio committed
44
45
46
47
48
49
50
51
52
53
54
55
RUN pwd
RUN ls

WORKDIR ..
COPY --chown="${APP_USER}:${APP_USER}" /controller/src ./src
RUN pwd
RUN ls

CMD ["python", "src/main.py"]