From 5af4ea4788752968f5128019d3ea498dbfa270e3 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Tue, 13 Mar 2018 01:03:42 -0400 Subject: [PATCH] Fixed Dockerfile --- .bashrc | 12 +++++++++ Dockerfile | 41 ++++++++++++++++++++++--------- README.md | 4 ++- mysslcerts/mysslcerts/settings.py | 6 ++--- start.sh | 9 +++++++ 5 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 .bashrc create mode 100644 start.sh diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..bf6d9be --- /dev/null +++ b/.bashrc @@ -0,0 +1,12 @@ +# .bashrc + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= + +# User specific aliases and functions +source /home/django-app/.virtualenv/bin/activate diff --git a/Dockerfile b/Dockerfile index 97f1c3b..aa3f8b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,37 @@ -FROM fedora -MAINTAINER http://fedoraproject.org/wiki/Cloud +FROM fedora:27 +MAINTAINER Marcelo Moreira de Mello +ENV PORT 8000 + +# create django-app user +RUN useradd django-app + +# update and install dependencies RUN dnf clean all && \ dnf -y update && \ dnf -y install python3 python3-devel python3-pip git \ - python3-virtualenv sqlite python-psycopg2 \ - openssl-devel && dnf clean all + python3-virtualenv sqlite openssl-devel && \ + dnf clean all + + +# create directory and mount sources there +ADD start.sh requirements.txt mysslcerts /home/django-app/code/ +RUN chmod +x /home/django-app/code/start.sh +ADD .bashrc /home/django-app/ +RUN chown django-app:django-app -R /home/django-app + +# set user +USER django-app +RUN /usr/bin/py3-virtualenv -p python3.6 /home/django-app/.virtualenv -COPY mysslcerts /code -RUN pip install -r /code/mysslcerts/requirements.txt +# set workdir +WORKDIR /home/django-app/code -# create directory /code and mount sources there -RUN mkdir /code -WORKDIR /code -VOLUME /code +# export volume +VOLUME /home/django-app/code -EXPOSE 8000 +# expose 8000 port +EXPOSE ${PORT} -CMD python mysslcerts/manage.py runserver 0.0.0.0:8000 +# define command to start container +ENTRYPOINT ["/bin/bash", "/home/django-app/code/start.sh"] diff --git a/README.md b/README.md index 99a7642..7757cda 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # my-ssl-certs Simple based Django application to request and sign custom SSL certificates - ### Credentials: admin: **mysslcerts** + +### Docker +docker run -p 8000:8000 tchellomello/mysslcerts:latest diff --git a/mysslcerts/mysslcerts/settings.py b/mysslcerts/mysslcerts/settings.py index 9bcbfc3..953856e 100644 --- a/mysslcerts/mysslcerts/settings.py +++ b/mysslcerts/mysslcerts/settings.py @@ -25,11 +25,9 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -## add the desired hosts here +## modify the desired hosts here ALLOWED_HOSTS = [ - 'localhost', - '127.0.0.1', - #'*', + '*', ] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..cbe38f6 --- /dev/null +++ b/start.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +PATH="/usr/bin:/usr/sbin" + +source /home/django-app/.virtualenv/bin/activate + +pip install -r /home/django-app/code/requirements.txt + +/home/django-app/code/manage.py runserver 0.0.0.0:${PORT}