diff --git a/docker-compose.yml b/docker-compose.yml index 955b6f2ed2..a487b0c71c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,9 @@ services: DJANGO_SETTINGS_MODULE: onadata.settings.docker build: context: . - dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu.dev + args: + INSTALL_DEV_DEPENDENCIES: "true" + dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu depends_on: - database - cache @@ -22,7 +24,9 @@ services: DJANGO_SETTINGS_MODULE: onadata.settings.docker build: context: . - dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu.dev + args: + INSTALL_DEV_DEPENDENCIES: "true" + dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu depends_on: - database - cache diff --git a/docker/onadata-uwsgi/Dockerfile.ubuntu b/docker/onadata-uwsgi/Dockerfile.ubuntu index 3de95b3ed3..9ef9f36888 100644 --- a/docker/onadata-uwsgi/Dockerfile.ubuntu +++ b/docker/onadata-uwsgi/Dockerfile.ubuntu @@ -27,6 +27,12 @@ RUN chown -R appuser:appuser /home/appuser/.pyenv USER appuser +ARG INSTALL_DEV_DEPENDENCIES=false +RUN if [ "$INSTALL_DEV_DEPENDENCIES" = "true" ]; then \ + git config --global http.version HTTP/1.1 && \ + git config --global http.postBuffer 524288000; \ + fi + # hadolint ignore=DL3013 RUN python -m pip install --no-cache-dir -U pip && \ python -m pip install --no-cache-dir -r requirements/base.pip && \ @@ -35,6 +41,10 @@ RUN python -m pip install --no-cache-dir -U pip && \ python -m pip install --no-cache-dir -r requirements/azure.pip && \ python -m pip install --no-cache-dir pyyaml==6.0.1 uwsgitop==0.12 supervisor==4.2.5 +RUN if [ "$INSTALL_DEV_DEPENDENCIES" = "true" ]; then \ + python -m pip install --no-cache-dir -r requirements/dev.pip; \ + fi + FROM base AS docs ENV PYENV_ROOT="$HOME/.pyenv" @@ -53,7 +63,7 @@ RUN python -m pip install --no-cache-dir -r requirements/docs.pip && \ make -C docs html -FROM debian:bookworm-20240722 as runtime +FROM debian:bookworm-20240701 as runtime ENV DEBIAN_FRONTEND=noninteractive diff --git a/docker/onadata-uwsgi/Dockerfile.ubuntu.dev b/docker/onadata-uwsgi/Dockerfile.ubuntu.dev deleted file mode 100644 index 729bfbec5d..0000000000 --- a/docker/onadata-uwsgi/Dockerfile.ubuntu.dev +++ /dev/null @@ -1,104 +0,0 @@ -FROM onaio/python-deps:3.10.14-20240703 AS base - -ARG optional_packages - -# Silence configuration prompts -ENV DEBIAN_FRONTEND=noninteractive - -ENV PYTHONUNBUFFERED=1 - -ENV DJANGO_SETTINGS_MODULE=onadata.settings.docker - -USER root - -RUN mkdir -p /root/.ssh && \ - ssh-keyscan github.com >> /root/.ssh/known_hosts && \ - mkdir -p /srv/onadata && \ - chown -R appuser:appuser /srv/onadata - -COPY ../../ /srv/onadata/ - -# Install service requirements -WORKDIR /srv/onadata - -# hadolint ignore=DL3013 -RUN --mount=type=ssh if [ -n "$optional_packages" ]; then /home/appuser/.pyenv/versions/3.10.14/bin/pip install --no-cache-dir ${optional_packages} ; fi -RUN chown -R appuser:appuser /home/appuser/.pyenv - -USER appuser - -RUN git config --global http.version HTTP/1.1 -RUN git config --global http.postBuffer 524288000 -# hadolint ignore=DL3013 -RUN python -m pip install --no-cache-dir -U pip && \ - python -m pip install --no-cache-dir -r requirements/base.pip && \ - python -m pip install --no-cache-dir -r requirements/s3.pip && \ - python -m pip install --no-cache-dir -r requirements/ses.pip && \ - python -m pip install --no-cache-dir -r requirements/azure.pip && \ - python -m pip install --no-cache-dir -r requirements/dev.pip && \ - python -m pip install --no-cache-dir pyyaml==6.0.1 uwsgitop==0.12 supervisor==4.2.5 - -FROM base AS docs - -ENV PYENV_ROOT="$HOME/.pyenv" -ENV PATH=$PYENV_ROOT/versions/3.10.14/bin:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH -COPY --from=base /home/appuser/.pyenv/ /home/appuser/.pyenv/ -COPY --from=base /srv/onadata/ /srv/onadata/ - -USER root - -RUN chown -R appuser:appuser /srv/onadata/ - -USER appuser - -# install sphinx and build API docs. -RUN python -m pip install --no-cache-dir -r requirements/docs.pip && \ - make -C docs html - - -FROM debian:bookworm-20240701 as runtime - -ENV DEBIAN_FRONTEND=noninteractive - -# Install prerequisite packages -RUN echo "deb http://deb.debian.org/debian unstable main non-free contrib" >> /etc/apt/sources.list \ - && apt-get update -q \ - && apt-get install -y --no-install-recommends locales netcat-traditional \ - && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \ - && dpkg-reconfigure locales - -ENV LC_ALL=en_US.UTF-8 -ENV LC_CTYPE=en_US.UTF-8 -ENV LANG=en_US.UTF-8 -ENV LANGUAGE=en_US.UTF-8 - - -# Install OnaData runtime dependencies -RUN apt-get install -y --no-install-recommends \ - gdal-bin \ - git-core \ - openjdk-11-jre-headless \ - libxml2-dev \ - libxslt1-dev \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* \ - && useradd -G tty -m appuser \ - && mkdir -p /srv/onadata \ - && chown -R appuser:appuser /srv/onadata - -COPY --from=base /home/appuser/.pyenv/ /home/appuser/.pyenv/ -COPY --from=docs /srv/onadata/ /srv/onadata/ -COPY --from=base /usr/local/lib/ /usr/lib/ - -RUN chown -R appuser:appuser /srv/onadata /home/appuser/.pyenv - -USER appuser -WORKDIR /srv/onadata - -ENV HOME=/home/appuser -ENV PYTHON_VERSION=3.10.14 -ENV PYENV_ROOT="$HOME/.pyenv" -ENV PATH=$PYENV_ROOT/versions/3.10.14/bin:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH - -CMD ["uwsgi", "--ini", "uwsgi.ini"]