Reduce docker image layers

This commit is contained in:
Raymond Tau
2019-03-19 08:45:33 +08:00
parent 0266e82143
commit db133e75db

View File

@@ -14,31 +14,45 @@
# Base system is the LTS version of Ubuntu. # Base system is the LTS version of Ubuntu.
FROM python:3.6-stretch FROM python:3.6-stretch
RUN groupadd -g 2300 tmpgroup && usermod -g tmpgroup www-data && groupdel www-data && groupadd -g 1000 www-data && usermod -g www-data www-data && usermod -u 1000 www-data && groupdel tmpgroup RUN groupadd -g 2300 tmpgroup \
&& usermod -g tmpgroup www-data \
&& groupdel www-data \
&& groupadd -g 1000 www-data \
&& usermod -g www-data www-data \
&& usermod -u 1000 www-data \
&& groupdel tmpgroup \
#
&& mkdir -p /srv/www/pinry/logs \
#
&& mkdir /data \
&& chown -R www-data:www-data /data \
#
&& mkdir -p /var/log/gunicorn \
&& apt-get update \
&& apt-get -y install nginx nginx-extras pwgen \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update RUN pip --no-cache-dir install pipenv gunicorn
RUN apt-get -y install nginx nginx-extras pwgen
RUN mkdir -p /srv/www/; cd /srv/www/; git clone https://github.com/pinry/pinry.git COPY Pipfile* /srv/www/pinry/
RUN mkdir /srv/www/pinry/logs; mkdir /data
RUN cd /srv/www/pinry && pip install pipenv && pipenv install --three --system RUN cd /srv/www/pinry \
RUN pip install gunicorn && pipenv install --three --system --clear
COPY . /srv/www/pinry/
# Fix permissions # Fix permissions
RUN chown -R www-data:www-data /srv/www RUN chown -R www-data:www-data /srv/www \
&& cd /srv/www/pinry \
&& python manage.py collectstatic --noinput
# Load in all of our config files. # Load in all of our config files.
ADD docker-contents/nginx/nginx.conf /etc/nginx/nginx.conf ADD docker/nginx/nginx.conf /etc/nginx/nginx.conf
ADD docker-contents/nginx/sites-enabled/default /etc/nginx/sites-enabled/default ADD docker/nginx/sites-enabled/default /etc/nginx/sites-enabled/default
ADD docker/scripts/* /scripts/
# Fix permissions
RUN mkdir /scripts/
ADD docker-contents/scripts/* /scripts/
RUN chown -R www-data:www-data /data
RUN mkdir /var/log/gunicorn
# 80 is for nginx web, /data contains static files and database /start runs it. # 80 is for nginx web, /data contains static files and database /start runs it.
expose 80 EXPOSE 80
volume ["/data"] VOLUME ["/data"]
cmd ["/scripts/start.sh"] CMD ["/scripts/start.sh"]