diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ca745b5c25..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM ubuntu:20.04 - -# Silence configuration prompts -ENV DEBIAN_FRONTEND noninteractive -ENV PYTHONUNBUFFERED 1 - -ENV DJANGO_SETTINGS_MODULE onadata.settings.docker - -# Install service dependencies -# hadolint ignore=DL3008 -RUN apt-get update -q &&\ - apt-get install -y --no-install-recommends software-properties-common \ - binutils \ - libproj-dev \ - gdal-bin \ - memcached \ - libmemcached-dev \ - build-essential \ - supervisor \ - python3.9 \ - python3-dev \ - python3-pip \ - python3-setuptools \ - git \ - libssl-dev \ - libpq-dev \ - gfortran \ - libatlas-base-dev \ - libjpeg-dev \ - libxml2-dev \ - libxslt1-dev \ - libpython3.9-dev \ - zlib1g-dev \ - ghostscript \ - python3-celery \ - python3-sphinx \ - pkg-config \ - gcc \ - automake \ - libtool \ - openjdk-11-jre-headless \ - libpcre3 \ - libpcre3-dev \ - locales \ - netcat && \ - apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade &&\ - rm -rf /var/lib/apt/lists/* - -# Generate and set en_US.UTF-8 locale -RUN locale-gen en_US.UTF-8 -ENV LC_ALL en_US.UTF-8 -ENV LC_CTYPE en_US.UTF-8 -RUN dpkg-reconfigure locales - -# Create OnaData user and add to tty group -RUN useradd -G tty -m onadata - -# Make app directory -RUN mkdir -p /srv/onadata && chown -R onadata:onadata /srv - -# Copy local codebase -COPY . /srv/onadata - -# Install service requirements -# hadolint ignore=DL3013 -RUN python3.9 -m pip install --no-cache-dir -U pip && \ - python3.9 -m pip install --no-cache-dir -r /srv/onadata/requirements/base.pip && \ - python3.9 -m pip install --no-cache-dir -r /srv/onadata/requirements/s3.pip && \ - python3.9 -m pip install --no-cache-dir -r /srv/onadata/requirements/ses.pip && \ - python3.9 -m pip install --no-cache-dir -r /srv/onadata/requirements/azure.pip && \ - python3.9 -m pip install --no-cache-dir uwsgitop django-silk - -WORKDIR /srv/onadata - -EXPOSE 8000 - -USER onadata - -CMD ["/usr/local/bin/uwsgi", "--ini", "/srv/onadata/uwsgi.ini"] diff --git a/docker-compose.yml b/docker-compose.yml index 5a295c925f..a1b8585c30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,13 +2,13 @@ services: api: build: context: . - dockerfile: Dockerfile + dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu + target: runserver depends_on: - database - cache stdin_open: true tty: true - user: "onadata" volumes: - ./:/srv/onadata ports: @@ -18,14 +18,14 @@ services: celery: build: context: . - dockerfile: Dockerfile + dockerfile: ./docker/onadata-uwsgi/Dockerfile.ubuntu + target: runserver depends_on: - database - cache - api volumes: - ./:/srv/onadata - user: "onadata" command: celery -A onadata.celeryapp worker -B -l INFO -E database: diff --git a/docker/onadata-uwsgi/Dockerfile.ubuntu b/docker/onadata-uwsgi/Dockerfile.ubuntu index ccc91edab3..b511802a4e 100644 --- a/docker/onadata-uwsgi/Dockerfile.ubuntu +++ b/docker/onadata-uwsgi/Dockerfile.ubuntu @@ -13,7 +13,7 @@ RUN mkdir -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts # hadolint ignore=DL3013 RUN --mount=type=ssh if [ -n "$optional_packages" ]; then pip install ${optional_packages} ; fi -FROM ubuntu:focal-20240123 +FROM ubuntu:focal-20240123 as base ARG release_version=v3.18.2 @@ -48,31 +48,31 @@ RUN add-apt-repository ppa:deadsnakes/ppa -y && apt-get update -q # Install OnaData Dependencies RUN apt-get install -y --no-install-recommends \ - libproj-dev \ - gdal-bin \ - memcached \ - libmemcached-dev \ - supervisor \ - python3.10 \ - python3.10-dev \ - python3-pip \ - python3-setuptools \ - libssl-dev \ - libpq-dev \ - gfortran \ - libatlas-base-dev \ - libjpeg-dev \ - libxml2-dev \ - libxslt1-dev \ - libpython3.10-dev \ - zlib1g-dev \ - ghostscript \ - python3-celery \ - python3-sphinx \ - libtool \ - openjdk-11-jre-headless \ - libpcre3 \ - libpcre3-dev \ + libproj-dev \ + gdal-bin \ + memcached \ + libmemcached-dev \ + supervisor \ + python3.10 \ + python3.10-dev \ + python3-pip \ + python3-setuptools \ + libssl-dev \ + libpq-dev \ + gfortran \ + libatlas-base-dev \ + libjpeg-dev \ + libxml2-dev \ + libxslt1-dev \ + libpython3.10-dev \ + zlib1g-dev \ + ghostscript \ + python3-celery \ + python3-sphinx \ + libtool \ + openjdk-11-jre-headless \ + libpcre3 \ + libpcre3-dev \ && apt-get autoremove -y \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* @@ -100,12 +100,16 @@ RUN python3.10 -m pip install --no-cache-dir -U pip && \ python3.10 -m pip install setuptools==65.5.1 && \ python3.10 -m pip install --no-cache-dir pyyaml uwsgitop - +FROM base as docs # Compile API Docs RUN make -C docs html +FROM base as runserver + EXPOSE 8000 +USER onadata + CMD ["/usr/local/bin/uwsgi", "--ini", "/uwsgi.ini"] -USER onadata + diff --git a/docker/onadata-uwsgi/docker-compose.yml b/docker/onadata-uwsgi/docker-compose.yml deleted file mode 100644 index 27ce6eb30b..0000000000 --- a/docker/onadata-uwsgi/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: '3' - -services: - db: - image: postgis/postgis:13-3.0 - environment: - - POSTGRES_PASSWORD=onadata - - POSTGRES_USER=onadata - - POSTGRES_DB=onadata - volumes: - # One level above the code to prevent having to move or delete - # it everytime we rebuild. - - ../../../.onadata_db:/var/lib/postgresql/data - queue: - image: rabbitmq - web: - build: - context: . - dockerfile: Dockerfile - image: onadata:latest - volumes: - # For local development - - ../../.:/srv/onadata - ports: - - "8000:8000" - depends_on: - - db - - queue