-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile-worker
55 lines (42 loc) · 2.15 KB
/
Dockerfile-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
FROM python:3.12-slim
ARG POETRY_VERSION=1.8.2
# install gfortran via apt and clean cache
# skipcq: DOK-DL3008
RUN apt-get update && apt-get install -y --no-install-recommends gfortran && rm -rf /var/lib/apt/lists/*
# set max celery task time to 10 hours
ENV CELERYD_TIME_LIMIT=36000
# set working directory
WORKDIR /usr/local/app
# add path where simulator binaries will be installed
ENV PATH="/simulators/shieldhit12a/bin:${PATH}"
ENV PATH="/simulators/topas/bin:${PATH}"
ENV PATH="/simulators/fluka/bin:${PATH}"
# set variable with path to Geant4 files required by TOPAS simulator
ENV TOPAS_G4_DATA_DIR="/simulators/geant4_files_path"
# openshift permissions
RUN chgrp -R 0 /usr/local/app && \
chmod -R g=u /usr/local/app
# Copy poetry configuration files
COPY poetry.lock poetry.toml pyproject.toml ./
# Install poetry and project dependencies, we also disabled virtualenv creation
ENV POETRY_VIRTUALENVS_CREATE=false
RUN pip install --no-cache-dir poetry==$POETRY_VERSION && poetry install --only main
# Copy worker script
COPY run_worker.sh .
# copy yaptide source code
COPY yaptide ./yaptide
# copy .gitsubmodules file to check if submodules are cloned correctly
COPY .gitmodules ./
# Some of our developers use Windows to run Docker, their bash scripts have CRLF line endings
# therefore when copied to the container they are not executable. This is a workaround to fix that.
# skipcq: DOK-W1001
RUN python3 -c "import os; content = open('run_worker.sh', 'rb').read().replace(b'\r\n', b'\n'); open('run_worker.sh', 'wb').write(content)"
# skipcq: DOK-W1001
RUN python3 -c "import os; content = open('yaptide/admin/simulators.py', 'rb').read().replace(b'\r\n', b'\n'); open('yaptide/admin/simulators.py', 'wb').write(content)"
# skipcq: DOK-W1001
RUN python3 -c "import os; content = open('yaptide/admin/simulator_storage.py', 'rb').read().replace(b'\r\n', b'\n'); open('yaptide/admin/simulator_storage.py', 'wb').write(content)"
# Make the scripts executable
# skipcq: DOK-W1001
RUN chmod +x run_worker.sh yaptide/admin/simulators.py
# Set the script as the entry point, Windows users require to run the script via bash, as `./` does not work
ENTRYPOINT ["bash", "run_worker.sh"]