Removed parts of Dockerfile, simplifying it and reducing the image size. Modified and simplified the docker entrypoint script. Tweaked the cleanup actions of docker/run.
- Legacy-Id: 10455
This commit is contained in:
parent
2191ec3cbd
commit
30c538790a
|
@ -1,3 +1,4 @@
|
|||
# -*- shell-mode -*-
|
||||
# This file is a docker (https://www.docker.com/what-docker) recipe, which can be used to build
|
||||
# a docker image which is ready to run a datatracker in development mode.
|
||||
#
|
||||
|
@ -32,7 +33,6 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||
|
||||
# Install needed packages
|
||||
RUN apt-get update && apt-get install -qy \
|
||||
apt-utils \
|
||||
ca-certificates \
|
||||
gawk \
|
||||
less \
|
||||
|
@ -45,45 +45,33 @@ RUN apt-get update && apt-get install -qy \
|
|||
pv \
|
||||
python \
|
||||
python-dev \
|
||||
python-m2crypto \
|
||||
subversion/wheezy-backports \
|
||||
wget \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set up root password
|
||||
RUN echo "root:codesprint" | chpasswd
|
||||
|
||||
# MySQL
|
||||
VOLUME /var/lib/mysql
|
||||
|
||||
# Pip
|
||||
ENV PYTHONWARNINGS="ignore:a true SSLContext object"
|
||||
WORKDIR /usr/src
|
||||
RUN wget -q https://bootstrap.pypa.io/get-pip.py
|
||||
RUN python get-pip.py
|
||||
RUN pip --version
|
||||
RUN wget -q https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm get-pip.py
|
||||
RUN pip install virtualenv
|
||||
|
||||
# idnits and dependencies
|
||||
RUN wget -q -P /usr/local/bin/ https://tools.ietf.org/tools/idnits/idnits
|
||||
RUN chmod +x /usr/local/bin/idnits
|
||||
RUN wget -q -P /usr/local/bin/ https://tools.ietf.org/tools/idnits/idnits && chmod +x /usr/local/bin/idnits
|
||||
|
||||
# A default user
|
||||
RUN useradd -m -s /bin/bash -u 500 django
|
||||
USER django
|
||||
WORKDIR /home/django
|
||||
|
||||
# Check out trunk, in order to verify setup by running tests
|
||||
RUN mkdir -p ~/src
|
||||
WORKDIR /home/django/src
|
||||
RUN svn co https://svn.tools.ietf.org/svn/tools/ietfdb/trunk trunk
|
||||
|
||||
# Set up a virtualenv, install requirements, run tests
|
||||
WORKDIR /home/django/src/trunk
|
||||
RUN virtualenv .
|
||||
RUN . bin/activate; pip install -r requirements.txt
|
||||
COPY settings_local.py ./settings_local.py
|
||||
RUN . bin/activate; ietf/manage.py test --settings=settings_sqlitetest
|
||||
|
||||
USER root
|
||||
WORKDIR /
|
||||
ENV DDIR="/usr/local/share/datatracker"
|
||||
RUN mkdir -p $DDIR
|
||||
WORKDIR $DDIR
|
||||
COPY requirements.txt ./
|
||||
COPY settings_local.py ./
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY docker-init.sh /docker-init.sh
|
||||
ENTRYPOINT ["/docker-init.sh"]
|
||||
|
|
|
@ -41,7 +41,7 @@ fi
|
|||
|
||||
if ! id -u "$USER" &> /dev/null; then
|
||||
echo "Creating user '$USER' ..."
|
||||
useradd -ms /bin/bash $USER
|
||||
useradd -s /bin/bash -G staff $USER
|
||||
fi
|
||||
|
||||
if [ ! -d /opt/home/$USER ]; then
|
||||
|
@ -49,45 +49,27 @@ if [ ! -d /opt/home/$USER ]; then
|
|||
mkdir -p /opt/home/$USER
|
||||
chown $USER /opt/home/$USER
|
||||
mkdir /opt/home/$USER/datatracker
|
||||
virtualenv /opt/home/$USER/datatracker
|
||||
virtualenv --system-site-packages /opt/home/$USER/datatracker
|
||||
fi
|
||||
|
||||
echo "Activating virtual python environment"
|
||||
echo "Activating a virtual python environment ..."
|
||||
cat /opt/home/$USER/datatracker/bin/activate >> /etc/bash.bashrc
|
||||
. /opt/home/$USER/datatracker/bin/activate
|
||||
|
||||
|
||||
if [ ! -d /opt/home/$USER/datatracker/lib/python2.7/site-packages/django ]; then
|
||||
echo "Installing requirements (based on trunk)"
|
||||
pip install -r /home/django/src/trunk/requirements.txt
|
||||
if ! python -c "import django"; then
|
||||
echo "Installing requirements ..."
|
||||
pip install -r /usr/local/share/datatracker/requirements.txt
|
||||
fi
|
||||
|
||||
if [ ! -f /opt/home/$USER/datatracker/lib/site-python/settings_local.py ]; then
|
||||
echo "Setting up a default settings_local.py"
|
||||
echo "Setting up a default settings_local.py ..."
|
||||
mkdir -p /opt/home/$USER/datatracker/lib/site-python/
|
||||
cp /home/django/src/trunk/settings_local.py /opt/home/$USER/datatracker/lib/site-python/
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
|
||||
FLAG1=/opt/home/$USER/.docker-init-flag-1
|
||||
if [ ! -f $FLAG1 ]; then
|
||||
touch $FLAG1
|
||||
cat <<-EOT
|
||||
|
||||
******************************************************************************
|
||||
|
||||
You should now cd to your svn working directory and update the datatracker
|
||||
prerequisites according to the requirements given in 'requirements.txt':
|
||||
|
||||
$ pip install -r requirements.txt
|
||||
|
||||
Happy coding!
|
||||
|
||||
******************************************************************************
|
||||
EOT
|
||||
cp /usr/local/share/datatracker/settings_local.py /opt/home/$USER/datatracker/lib/site-python/
|
||||
fi
|
||||
|
||||
chown -R $USER /opt/home/$USER
|
||||
cd /home/$USER
|
||||
|
||||
echo "Done!"
|
||||
|
||||
su $USER
|
||||
|
|
|
@ -136,5 +136,5 @@ docker commit $latest levkowetz/datatracker:latest
|
|||
|
||||
echo "Cleaning up containers and images"
|
||||
docker rm $latest
|
||||
docker rmi -f $(docker images -f dangling=true -q)
|
||||
docker images -f dangling=true -q | xargs docker rmi -f
|
||||
|
||||
|
|
Loading…
Reference in a new issue