UPD: so many improvements :)
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -1,16 +1,20 @@
|
||||
FROM fedora
|
||||
|
||||
RUN dnf -y update && \
|
||||
dnf -y install procps-ng && \
|
||||
dnf -y install httpd && \
|
||||
dnf -y install python3-mod_wsgi && \
|
||||
dnf clean all
|
||||
|
||||
COPY container-files/ /
|
||||
COPY container-files/httpd-layer/ /
|
||||
|
||||
COPY django-test /usr/local/share/django-test
|
||||
RUN /usr/local/bin/install-django-test.sh /usr/local/share/django-test
|
||||
COPY django-test /srv/src/django-test
|
||||
COPY container-files/django-test-layer/ /
|
||||
RUN /srv/bin/setup-django-test.sh /srv/django-test /srv/src/django-test
|
||||
|
||||
EXPOSE 80
|
||||
COPY container-files/docker-entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["/usr/local/sbin/start-httpd.sh"]
|
||||
EXPOSE 80/tcp
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["--"]
|
||||
|
||||
3
Makefile
3
Makefile
@@ -14,5 +14,4 @@ image:
|
||||
$(DOCKER) build -t $(IMAGE_NAME) .
|
||||
|
||||
test-run:
|
||||
$(DOCKER) run -ti -p 80:80 --name $(APPLICATION_NAME) $(IMAGE_NAME)
|
||||
$(DOCKER) rm $(APPLICATION_NAME)
|
||||
$(DOCKER) run -ti --rm -p 80:80 $(IMAGE_NAME)
|
||||
|
||||
3
README
3
README
@@ -1,3 +0,0 @@
|
||||
git clone https://heinzelwelt.de/vcs/python/django-test
|
||||
make image
|
||||
make test-run
|
||||
48
README.rst
Normal file
48
README.rst
Normal file
@@ -0,0 +1,48 @@
|
||||
ABOUT
|
||||
=====
|
||||
Docker container for django-test.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
The docker image is derivated from
|
||||
Fedora image (https://hub.docker.com/_/fedora).
|
||||
|
||||
It will contain and run
|
||||
|
||||
- apache httpd
|
||||
- python3 mod_wsgi
|
||||
- django-test django application
|
||||
|
||||
|
||||
BUILD
|
||||
=====
|
||||
- ``git clone https://heinzelwelt.de/vcs/python/django-test``
|
||||
- ``docker build -t IMAGE_NAME .``
|
||||
|
||||
|
||||
USAGE
|
||||
=====
|
||||
- ``docker run -d -p 80:80 -e LOG_LEVEL=error IMAGE_NAME``
|
||||
|
||||
The httpd process is listening on port 80/tcp.
|
||||
|
||||
The httpd error log will be written to stderr, so it can be
|
||||
obtained with ``docker logs``
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
=============
|
||||
The following **environment variables** are supported:
|
||||
|
||||
- LOG_LEVEL
|
||||
-- to set the httpd LogLevel directive
|
||||
- SERVER_ADMIN
|
||||
-- to set the httpd ServerAdmin directive
|
||||
|
||||
|
||||
LICENCE
|
||||
=======
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
WSGIDaemonProcess django-test display-name=django-test python-home=/srv/django-test/python python-path=/srv/django-test/django
|
||||
|
||||
Alias /static/ "/srv/django-test/django/var/www/static/"
|
||||
<Directory "/srv/django-test/django/var/www/static">
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
WSGIScriptAlias / "/srv/django-test/django/main/wsgi.py"
|
||||
<Directory "/srv/django-test/django/main">
|
||||
WSGIProcessGroup django-test
|
||||
WSGIPassAuthorization On
|
||||
AllowOverride None
|
||||
Options FollowSymLinks
|
||||
<Files wsgi.py>
|
||||
Require all granted
|
||||
</Files>
|
||||
</Directory>
|
||||
@@ -2,17 +2,29 @@
|
||||
|
||||
### config ###
|
||||
PROJECT_NAME="django-test"
|
||||
PROJECT_REPO="git+https://heinzelwelt.de/vcs/python/django-test"
|
||||
SETUP_COMMAND="django-test-admin"
|
||||
|
||||
INSTALL_DIR="/var/www/wsgi/${PROJECT_NAME}"
|
||||
INSTALL_DIR="/srv/${PROJECT_NAME}"
|
||||
VENV_DIR="python"
|
||||
VENV_PATH="${INSTALL_DIR}/${VENV_DIR}"
|
||||
DJANGO_DIR="django"
|
||||
DJANGO_PATH="${INSTALL_DIR}/${DJANGO_DIR}"
|
||||
DJANGO_MAIN_MODULE="main"
|
||||
|
||||
PROJECT_REPO="git+https://heinzelwelt.de/vcs/python/django-test"
|
||||
|
||||
### argv ###
|
||||
if test "$1" != "" -a -d "$1" ; then
|
||||
PROJECT_REPO="$1"
|
||||
if test "$1" != "" ; then
|
||||
if test "$1" != "-" ; then
|
||||
INSTALL_DIR="$1"
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
if test "$1" != "" ; then
|
||||
if test "$1" != "-" ; then
|
||||
PROJECT_REPO="$1"
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
|
||||
### action ###
|
||||
@@ -21,13 +33,13 @@ python3 -m venv "${VENV_PATH}"
|
||||
source "${VENV_PATH}/bin/activate"
|
||||
pip install --upgrade pip
|
||||
pip install "$PROJECT_REPO"
|
||||
django-test-admin setup "${DJANGO_PATH}"
|
||||
$SETUP_COMMAND setup "${DJANGO_PATH}"
|
||||
python3 "${DJANGO_PATH}/manage.py" collectstatic --noinput
|
||||
|
||||
cat <<E-O-H >> "${DJANGO_PATH}/main/settings.py"
|
||||
cat <<E-O-H >> "${DJANGO_PATH}/${DJANGO_MAIN_MODULE}/settings.py"
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
E-O-H
|
||||
|
||||
### end ###
|
||||
16
container-files/docker-entrypoint.sh
Executable file
16
container-files/docker-entrypoint.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Disable CustomLog, that is configured by default in upstream.
|
||||
sed -i -e 's:^\(\s*\)\(CustomLog\s\s*"logs/access_log"\):\1# Disabled by /docker-entrypoint.sh # \2:' \
|
||||
/etc/httpd/conf/httpd.conf
|
||||
|
||||
# Remove left-overs from an incomplete shutdown previously.
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
|
||||
if test "X${SERVER_ADMIN}" != "X" ; then
|
||||
set -- -c "ServerAdmin $SERVER_ADMIN" "$@"
|
||||
fi
|
||||
if test "X${LOG_LEVEL}" != "X" ; then
|
||||
set -- -c "LogLevel $LOG_LEVEL" "$@"
|
||||
fi
|
||||
exec /usr/sbin/httpd -DFOREGROUND "$@"
|
||||
@@ -1,18 +0,0 @@
|
||||
WSGIDaemonProcess django-test processes=1 threads=4 display-name=django-test python-home=/var/www/wsgi/django-test/python python-path=/var/www/wsgi/django-test/django
|
||||
|
||||
Alias /static/ "/var/www/wsgi/django-test/django/var/www/static/"
|
||||
<Directory "/var/www/wsgi/django-test/django/var/www/static">
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
WSGIScriptAlias / "/var/www/wsgi/django-test/django/main/wsgi.py"
|
||||
<Directory "/var/www/wsgi/django-test/django/main">
|
||||
WSGIProcessGroup django-test
|
||||
WSGIPassAuthorization On
|
||||
AllowOverride None
|
||||
Options FollowSymLinks
|
||||
<Files wsgi.py>
|
||||
Require all granted
|
||||
</Files>
|
||||
</Directory>
|
||||
@@ -1,6 +1,4 @@
|
||||
# /etc/httpd/conf.d/defaults.conf
|
||||
|
||||
ServerAdmin heinzel@heinzelwelt.de
|
||||
ServerTokens Prod
|
||||
ErrorLog /dev/stderr
|
||||
LogLevel info
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec /usr/sbin/httpd -DFOREGROUND $@
|
||||
Reference in New Issue
Block a user