Skip to content

Commit

Permalink
Docker: Use Ubuntu 22.04 and pyenv install Python
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanga committed May 1, 2024
1 parent d28c455 commit 147457b
Showing 1 changed file with 4 additions and 102 deletions.
106 changes: 4 additions & 102 deletions docker/onadata-uwsgi/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,110 +1,12 @@
FROM python:3.10 as intermediate

ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONUNBUFFERED 1

FROM python:3.10.14 as demo
ARG optional_packages

# Download public key for github.com
RUN mkdir -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

# Install optional requirements
# Read more on the ssh argument here: https://docs.docker.com/develop/develop-images/build_enhancements/#using-ssh-to-access-private-data-in-builds
# hadolint ignore=DL3013
RUN --mount=type=ssh if [ -n "$optional_packages" ]; then pip install ${optional_packages} ; fi

FROM ubuntu:focal-20240123

ARG release_version=v3.18.2

# Silence configuration prompts
ENV DEBIAN_FRONTEND noninteractive

ENV PYTHONUNBUFFERED 1

ENV DJANGO_SETTINGS_MODULE onadata.settings.docker

# Install prerequisite packages
RUN apt-get update -q && \
apt-get install -y --no-install-recommends \
software-properties-common \
binutils \
build-essential \
locales \
netcat \
gcc \
pkg-config \
git \
automake

# 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

# Add Deadsnake Repository
# Install OnaData Dependencies
RUN add-apt-repository 'ppa:deadsnakes/ppa' -y \
&& apt-get update -q \
&& 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 \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Create OnaData user and add to tty group
RUN useradd -G tty -m onadata

# Clone Repository and Change owner
RUN mkdir -p /srv/onadata

COPY ../../ /srv/onadata/

RUN chown -R onadata:onadata /srv/onadata

# Install service requirements
WORKDIR /srv/onadata

COPY --from=intermediate /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/dist-packages/
# hadolint ignore=DL3013
RUN python3.10 -m pip install --no-cache-dir -U pip && \
python3.10 -m pip install --no-cache-dir -r requirements/base.pip && \
python3.10 -m pip install --no-cache-dir -r requirements/s3.pip && \
python3.10 -m pip install --no-cache-dir -r requirements/ses.pip && \
python3.10 -m pip install --no-cache-dir -r requirements/azure.pip && \
python3.10 -m pip install setuptools==65.5.1 && \
python3.10 -m pip install --no-cache-dir pyyaml uwsgitop

# Compile API Docs
RUN make -C docs html

EXPOSE 8000

USER onadata
# Download public key for github.com
RUN mkdir -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

CMD ["/usr/local/bin/uwsgi", "--ini", "/uwsgi.ini"]
RUN --mount=type=ssh if [ -n "$optional_packages" ]; then pip install --no-cache-dir ${optional_packages} ; fi

0 comments on commit 147457b

Please sign in to comment.