-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDockerfile.api_server
executable file
·80 lines (67 loc) · 2.94 KB
/
Dockerfile.api_server
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
# ---- STAGE 1 -----
FROM ubuntu:24.04 AS build-packages
ENV PIP_BREAK_SYSTEM_PACKAGES 1
ENV DEBIAN_FRONTEND noninteractive
COPY ./requirements-server.txt ./requirements-server.txt
RUN apt-get update && apt-get install -y --no-install-recommends gcc build-essential python3 python3-pip python3-dev pkg-config libmariadb-dev-compat && rm -rf /var/lib/apt/lists/*
RUN pip install --user --no-warn-script-location -r ./requirements-server.txt && pip install --no-warn-script-location --user mysqlclient
# 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 server
# ---- STAGE 2 ----
FROM ubuntu:24.04
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends sudo python3 python3-pkg-resources curl libmariadbclient-dev-compat \
&& rm -rf /var/lib/apt/lists/
ARG USER_ID=1000
RUN userdel -r ubuntu
RUN useradd -u ${USER_ID} --home /home/server --shell /bin/bash server
COPY --chown=server:server --from=build-packages /root/.local /home/server/.local
RUN mkdir -p /var/log/oasis /shared-fs && chmod 777 -R /var/log/oasis
WORKDIR /var/www/oasis
COPY ./requirements-server.txt ./requirements.txt
COPY ./src/startup_server.sh /usr/local/bin/startup
COPY ./src/utils/wait-for-it.sh /usr/local/bin/wait-for-it
COPY ./src/utils/wait-for-server.sh /usr/local/bin/wait-for-server
COPY ./src/utils/plat2-migration-helper.sh /usr/local/bin/migration-helper.sh
COPY ./asgi ./asgi
COPY ./wsgi ./wsgi
COPY ./conf.ini ./
COPY manage.py .
COPY ./src/utils/set_default_user.py .
COPY ./src/utils/server_bashrc /home/server/.bashrc
COPY ./src/server /var/www/oasis/src/server
COPY ./src/common /var/www/oasis/src/common
COPY ./src/conf /var/www/oasis/src/conf
COPY ./VERSION /var/www/oasis/VERSION
RUN chown -R server:server /shared-fs \
/var/www/oasis \
&& chmod +x ./asgi/run-asgi.sh \
/usr/local/bin/startup \
/usr/local/bin/wait-for-it \
/usr/local/bin/migration-helper.sh
USER server
RUN OASIS_API_SECRET_KEY=supersecret python3 manage.py collectstatic --noinput
ENV PIP_BREAK_SYSTEM_PACKAGES 1
ENV OASIS_SERVER_DB_ENGINE django.db.backends.mysql
ENV OASIS_MEDIA_ROOT=/shared-fs
ENV OASIS_DEBUG=false
ENV PATH=/home/server/.local/bin:$PATH
EXPOSE 8000
EXPOSE 8001
EXPOSE 51970
ENTRYPOINT ["startup"]
CMD ["./wsgi/run-wsgi.sh"]