Skip to content

Commit 30c5387

Browse files
committed
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
1 parent 2191ec3 commit 30c5387

3 files changed

Lines changed: 25 additions & 55 deletions

File tree

docker/Dockerfile

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- shell-mode -*-
12
# This file is a docker (https://www.docker.com/what-docker) recipe, which can be used to build
23
# a docker image which is ready to run a datatracker in development mode.
34
#
@@ -32,7 +33,6 @@ ENV DEBIAN_FRONTEND=noninteractive
3233

3334
# Install needed packages
3435
RUN apt-get update && apt-get install -qy \
35-
apt-utils \
3636
ca-certificates \
3737
gawk \
3838
less \
@@ -45,45 +45,33 @@ RUN apt-get update && apt-get install -qy \
4545
pv \
4646
python \
4747
python-dev \
48+
python-m2crypto \
4849
subversion/wheezy-backports \
4950
wget \
5051
&& apt-get clean \
5152
&& rm -rf /var/lib/apt/lists/*
5253

54+
# Set up root password
55+
RUN echo "root:codesprint" | chpasswd
56+
5357
# MySQL
5458
VOLUME /var/lib/mysql
5559

5660
# Pip
5761
ENV PYTHONWARNINGS="ignore:a true SSLContext object"
5862
WORKDIR /usr/src
59-
RUN wget -q https://bootstrap.pypa.io/get-pip.py
60-
RUN python get-pip.py
61-
RUN pip --version
63+
RUN wget -q https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm get-pip.py
6264
RUN pip install virtualenv
6365

6466
# idnits and dependencies
65-
RUN wget -q -P /usr/local/bin/ https://tools.ietf.org/tools/idnits/idnits
66-
RUN chmod +x /usr/local/bin/idnits
67-
68-
# A default user
69-
RUN useradd -m -s /bin/bash -u 500 django
70-
USER django
71-
WORKDIR /home/django
72-
73-
# Check out trunk, in order to verify setup by running tests
74-
RUN mkdir -p ~/src
75-
WORKDIR /home/django/src
76-
RUN svn co https://svn.tools.ietf.org/svn/tools/ietfdb/trunk trunk
77-
78-
# Set up a virtualenv, install requirements, run tests
79-
WORKDIR /home/django/src/trunk
80-
RUN virtualenv .
81-
RUN . bin/activate; pip install -r requirements.txt
82-
COPY settings_local.py ./settings_local.py
83-
RUN . bin/activate; ietf/manage.py test --settings=settings_sqlitetest
67+
RUN wget -q -P /usr/local/bin/ https://tools.ietf.org/tools/idnits/idnits && chmod +x /usr/local/bin/idnits
8468

85-
USER root
86-
WORKDIR /
69+
ENV DDIR="/usr/local/share/datatracker"
70+
RUN mkdir -p $DDIR
71+
WORKDIR $DDIR
72+
COPY requirements.txt ./
73+
COPY settings_local.py ./
74+
RUN pip install -r requirements.txt
8775

8876
COPY docker-init.sh /docker-init.sh
8977
ENTRYPOINT ["/docker-init.sh"]

docker/docker-init.sh

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,53 +41,35 @@ fi
4141

4242
if ! id -u "$USER" &> /dev/null; then
4343
echo "Creating user '$USER' ..."
44-
useradd -ms /bin/bash $USER
44+
useradd -s /bin/bash -G staff $USER
4545
fi
4646

4747
if [ ! -d /opt/home/$USER ]; then
4848
echo "Setting up python virtualenv at /opt/home/$USER ..."
4949
mkdir -p /opt/home/$USER
5050
chown $USER /opt/home/$USER
5151
mkdir /opt/home/$USER/datatracker
52-
virtualenv /opt/home/$USER/datatracker
52+
virtualenv --system-site-packages /opt/home/$USER/datatracker
5353
fi
5454

55-
echo "Activating virtual python environment"
55+
echo "Activating a virtual python environment ..."
5656
cat /opt/home/$USER/datatracker/bin/activate >> /etc/bash.bashrc
5757
. /opt/home/$USER/datatracker/bin/activate
5858

59-
60-
if [ ! -d /opt/home/$USER/datatracker/lib/python2.7/site-packages/django ]; then
61-
echo "Installing requirements (based on trunk)"
62-
pip install -r /home/django/src/trunk/requirements.txt
59+
if ! python -c "import django"; then
60+
echo "Installing requirements ..."
61+
pip install -r /usr/local/share/datatracker/requirements.txt
6362
fi
6463

6564
if [ ! -f /opt/home/$USER/datatracker/lib/site-python/settings_local.py ]; then
66-
echo "Setting up a default settings_local.py"
65+
echo "Setting up a default settings_local.py ..."
6766
mkdir -p /opt/home/$USER/datatracker/lib/site-python/
68-
cp /home/django/src/trunk/settings_local.py /opt/home/$USER/datatracker/lib/site-python/
69-
fi
70-
71-
echo "Done."
72-
73-
FLAG1=/opt/home/$USER/.docker-init-flag-1
74-
if [ ! -f $FLAG1 ]; then
75-
touch $FLAG1
76-
cat <<-EOT
77-
78-
******************************************************************************
79-
80-
You should now cd to your svn working directory and update the datatracker
81-
prerequisites according to the requirements given in 'requirements.txt':
82-
83-
$ pip install -r requirements.txt
84-
85-
Happy coding!
86-
87-
******************************************************************************
88-
EOT
67+
cp /usr/local/share/datatracker/settings_local.py /opt/home/$USER/datatracker/lib/site-python/
8968
fi
9069

9170
chown -R $USER /opt/home/$USER
9271
cd /home/$USER
72+
73+
echo "Done!"
74+
9375
su $USER

docker/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ docker commit $latest levkowetz/datatracker:latest
136136

137137
echo "Cleaning up containers and images"
138138
docker rm $latest
139-
docker rmi -f $(docker images -f dangling=true -q)
139+
docker images -f dangling=true -q | xargs docker rmi -f
140140

0 commit comments

Comments
 (0)