-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDockerfile.model_worker
executable file
·84 lines (72 loc) · 3 KB
/
Dockerfile.model_worker
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
81
82
83
84
# ---- STAGE 1 -----
FROM ubuntu:24.04 AS build-packages
# Build python packages
ENV PIP_BREAK_SYSTEM_PACKAGES 1
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libspatialindex-dev git curl g++ build-essential libtool autoconf automake python3-dev python3 python3-pip pkg-config
COPY ./requirements-worker.txt ./requirements-worker.txt
RUN pip3 install --user --no-warn-script-location -r ./requirements-worker.txt
# Install MDK from git branch (Optional) 'docker build --build-arg oasislmf_branch=develop'
ARG oasislmf_branch
RUN if [ ! -z "$oasislmf_branch" ] ; then \
apt update && apt install -y git; \
pip uninstall oasislmf -y; \
pip install --user --no-warn-script-location -v git+https://[email protected]/OasisLMF/OasisLMF.git@${oasislmf_branch}#egg=oasislmf[extra]; \
fi
# Install ODS-Tools from git branch (Optional) 'docker build --build-arg ods_tools_branch=develop'
ARG ods_tools_branch
RUN if [ ! -z "$ods_tools_branch" ] ; then \
apt update && apt install -y git; \
pip uninstall ods-tools -y; \
pip install --user --no-warn-script-location -v git+https://[email protected]/OasisLMF/ODS_Tools.git@${ods_tools_branch}#egg=ods-tools; \
fi
# Install Oasis-Data-Manager from git branch (Optional) 'docker build --build-arg odm_branch=develop'
ARG odm_branch
RUN if [ ! -z "$odm_branch" ] ; then \
apt update && apt install -y git; \
pip uninstall oasis-data-manager -y; \
pip install --user --no-warn-script-location -v git+https://[email protected]/OasisLMF/OasisDataManager.git@${odm_branch}#egg=oasis-data-manager; \
fi
USER worker
# ---- STAGE 2 ----
FROM ubuntu:24.04
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends vim git python3 python3-pip libspatialindex-dev curl procps \
&& rm -rf /var/lib/apt/lists/*
# Copy built python packages
ARG USER_ID=1000
RUN userdel -r ubuntu
RUN useradd -u ${USER_ID} --home /home/worker --shell /bin/bash worker
COPY --chown=worker:worker --from=build-packages /root/.local /home/worker/.local
# Copy in worker files
WORKDIR /home/worker
COPY ./requirements-worker.txt ./requirements.txt
COPY --chown=worker:worker ./conf.ini ./
COPY ./src/startup_worker.sh ./startup.sh
COPY ./src/__init__.py ./src/
COPY ./src/common ./src/common/
COPY ./src/conf ./src/conf/
COPY ./src/model_execution_worker/ ./src/model_execution_worker/
COPY ./src/utils/ ./src/utils/
COPY ./src/utils/worker_bashrc /home/worker/.bashrc
# Add required directories
RUN mkdir -p /var/oasis && \
mkdir -p /home/worker/model && \
mkdir -p /var/log/oasis/tasks && \
mkdir -p /shared-fs && \
touch /var/log/oasis/worker.log && \
chmod 777 /var/log/oasis/worker.log
RUN chown -R worker:worker /var/oasis \
/var/log \
/shared-fs
# Enviroment setup
COPY ./VERSION ./
USER worker
ENV PATH=/home/worker/.local/bin:$PATH
ENV PIP_BREAK_SYSTEM_PACKAGES 1
ENV DEBIAN_FRONTEND=noninteractive
ENV OASIS_MEDIA_ROOT=/shared-fs
ENV OASIS_ENV_OVERRIDE=true
ENV OASIS_CHECK_MISSING_INPUTS=true
ENTRYPOINT ./startup.sh