UPD: i like it now.
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -1,20 +1,33 @@
|
||||
FROM fedora
|
||||
|
||||
LABEL maintainer="Jens Kleineheismann <heinzel@heinzelwelt.de>"
|
||||
|
||||
ARG APPLICATION_NAME=django-test
|
||||
ARG APPLICATION_SRC=src/${APPLICATION_NAME}
|
||||
|
||||
RUN dnf -y update && \
|
||||
dnf -y install procps-ng && \
|
||||
dnf -y install procps-ng iproute net-tools && \
|
||||
dnf -y install httpd && \
|
||||
dnf -y install python3-mod_wsgi && \
|
||||
dnf clean all
|
||||
|
||||
COPY container-files/httpd-layer/ /
|
||||
RUN chown apache: /etc/httpd/run && \
|
||||
setcap 'cap_net_bind_service=+ep' /usr/sbin/httpd && \
|
||||
sed -i -e 's:^\(\s.*\)\(CustomLog\s.*\)$:\1#\2:' \
|
||||
/etc/httpd/conf/httpd.conf
|
||||
|
||||
COPY src/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
|
||||
COPY container-filesystem/ /
|
||||
COPY $APPLICATION_SRC /srv/${APPLICATION_NAME}/src/${APPLICATION_NAME}
|
||||
|
||||
COPY container-files/docker-entrypoint.sh /
|
||||
RUN ln -s ${APPLICATION_NAME} /srv/application && \
|
||||
/setup-application.sh /srv/${APPLICATION_NAME} \
|
||||
/srv/${APPLICATION_NAME}/src/${APPLICATION_NAME} && \
|
||||
rm /setup-application.sh
|
||||
|
||||
EXPOSE 80/tcp
|
||||
ENV LOG_LEVEL error
|
||||
|
||||
USER apache
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["--"]
|
||||
|
||||
16
Makefile
16
Makefile
@@ -3,10 +3,14 @@ REPO_URL := https://heinzelwelt.de/vcs/python/django-test
|
||||
REPO_DIR := src/$(APPLICATION_NAME)
|
||||
IMAGE_NAME := $(APPLICATION_NAME)
|
||||
|
||||
HOST_PORT := 80
|
||||
CONTAINER_PORT := 80
|
||||
|
||||
DOCKER := docker
|
||||
DGOSS := dgoss
|
||||
GIT := git
|
||||
|
||||
.PHONY: default help image test-run dist-clean
|
||||
.PHONY: default help image test test-run dist-clean
|
||||
|
||||
default: image
|
||||
|
||||
@@ -17,12 +21,18 @@ $(REPO_DIR):
|
||||
$(GIT) clone $(REPO_URL) $@
|
||||
|
||||
$(IMAGE_NAME): $(REPO_DIR)
|
||||
$(DOCKER) build -t $(IMAGE_NAME) .
|
||||
$(DOCKER) build --build-arg APPLICATION_NAME=$(APPLICATION_NAME) -t $(IMAGE_NAME) .
|
||||
|
||||
image: $(IMAGE_NAME)
|
||||
|
||||
test:
|
||||
$(DGOSS) run $(IMAGE_NAME)
|
||||
|
||||
test-run:
|
||||
$(DOCKER) run -ti --rm -p 80:80 $(IMAGE_NAME)
|
||||
$(DOCKER) run -ti --rm -p $(HOST_PORT):$(CONTAINER_PORT) $(IMAGE_NAME)
|
||||
|
||||
enter:
|
||||
$(DOCKER) run -ti --rm -p $(HOST_PORT):$(CONTAINER_PORT) --entrypoint /bin/bash $(IMAGE_NAME)
|
||||
|
||||
dist-clean:
|
||||
-rm -rf $(REPO_DIR)
|
||||
|
||||
21
README.rst
21
README.rst
@@ -3,10 +3,15 @@ ABOUT
|
||||
Docker container for django-test.
|
||||
|
||||
|
||||
AUTHOR
|
||||
======
|
||||
Jens Kleineheismann <heinzel@heinzelwelt.de>
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
The django-heinzel docker image is derivated from
|
||||
Fedora image (https://hub.docker.com/_/fedora).
|
||||
This docker image is derivated from the official Fedora image
|
||||
(https://hub.docker.com/_/fedora).
|
||||
|
||||
It will contain and run
|
||||
|
||||
@@ -18,16 +23,18 @@ It will contain and run
|
||||
BUILD
|
||||
=====
|
||||
- ``make``
|
||||
- ``make test``
|
||||
|
||||
or alternatively the *long* way:
|
||||
|
||||
- ``git clone https://heinzelwelt.de/vcs/python/django-test src/django-test``
|
||||
- ``docker build -t IMAGE_NAME .``
|
||||
- ``docker build -t django-test .``
|
||||
- ``dgoss run django-test``
|
||||
|
||||
|
||||
USAGE
|
||||
=====
|
||||
- ``docker run -d -p 80:80 -e SERVER_ADMIN=heinzel@heinzelwelt.de IMAGE_NAME``
|
||||
- ``docker run -d -p 80:80 django-test``
|
||||
|
||||
The httpd process is listening on port 80/tcp.
|
||||
|
||||
@@ -37,16 +44,14 @@ obtained with ``docker logs``
|
||||
|
||||
CONFIGURATION
|
||||
=============
|
||||
The following **environment variables** are supported:
|
||||
The following **environment variables** are supported and
|
||||
can be set with the -e option of the ``docker run`` command:
|
||||
|
||||
- LOG_LEVEL (default: error)
|
||||
-- to set the httpd LogLevel directive
|
||||
- SERVER_ADMIN (default: root@localhost)
|
||||
-- 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.
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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>
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
DEFAULT_LOG_LEVEL="error"
|
||||
|
||||
# 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
|
||||
set -- -c "LogLevel ${LOG_LEVEL:-${DEFAULT_LOG_LEVEL}}" "$@"
|
||||
exec /usr/sbin/httpd -DFOREGROUND "$@"
|
||||
10
container-filesystem/docker-entrypoint.sh
Executable file
10
container-filesystem/docker-entrypoint.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Remove left-overs from an incomplete shutdown previously.
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
|
||||
exec /usr/sbin/httpd \
|
||||
-DFOREGROUND \
|
||||
-c "LogLevel ${LOG_LEVEL:-error}" \
|
||||
-c "ServerName ${HOSTNAME}" \
|
||||
"$@"
|
||||
9
container-filesystem/etc/bashrc.local
Normal file
9
container-filesystem/etc/bashrc.local
Normal file
@@ -0,0 +1,9 @@
|
||||
# /etc/bashrc.local
|
||||
|
||||
PS1='\u@\w/ \$ '
|
||||
export PS1
|
||||
|
||||
alias ls="ls -F --color"
|
||||
alias l="ls -ahl"
|
||||
|
||||
#end
|
||||
18
container-filesystem/etc/httpd/conf.d/application.conf
Normal file
18
container-filesystem/etc/httpd/conf.d/application.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
WSGIDaemonProcess wsgi-daemon display-name=wsgi-daemon python-home=/srv/application/python python-path=/srv/application/django
|
||||
|
||||
Alias /static/ "/srv/application/django/var/www/static/"
|
||||
<Directory "/srv/application/django/var/www/static">
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
WSGIScriptAlias / "/srv/application/django/main/wsgi.py"
|
||||
<Directory "/srv/application/django/main">
|
||||
WSGIProcessGroup wsgi-daemon
|
||||
WSGIPassAuthorization On
|
||||
AllowOverride None
|
||||
Options FollowSymLinks
|
||||
<Files wsgi.py>
|
||||
Require all granted
|
||||
</Files>
|
||||
</Directory>
|
||||
1
container-filesystem/etc/httpd/conf.d/wsgi.conf
Normal file
1
container-filesystem/etc/httpd/conf.d/wsgi.conf
Normal file
@@ -0,0 +1 @@
|
||||
WSGISocketPrefix run/wsgi
|
||||
@@ -1,18 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
### config ###
|
||||
PROJECT_NAME="django-test"
|
||||
PROJECT_REPO="git+https://heinzelwelt.de/vcs/python/django-test"
|
||||
SETUP_COMMAND="django-test-admin"
|
||||
|
||||
INSTALL_DIR="/srv/${PROJECT_NAME}"
|
||||
INSTALL_DIR="${HOME}"
|
||||
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" != "" ; then
|
||||
if test "$1" != "-" ; then
|
||||
@@ -27,19 +23,30 @@ if test "$1" != "" ; then
|
||||
shift
|
||||
fi
|
||||
|
||||
VENV_PATH="${INSTALL_DIR}/${VENV_DIR}"
|
||||
DJANGO_PATH="${INSTALL_DIR}/${DJANGO_DIR}"
|
||||
DJANGO_SETTINGS_FILE="${DJANGO_PATH}/${DJANGO_MAIN_MODULE}/settings.py"
|
||||
|
||||
### action ###
|
||||
echo "Setup application in $INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
echo "Setup python environment"
|
||||
python3 -m venv "${VENV_PATH}"
|
||||
source "${VENV_PATH}/bin/activate"
|
||||
pip install --upgrade pip
|
||||
echo "Install application from $PROJECT_REPO"
|
||||
pip install "$PROJECT_REPO"
|
||||
echo "Setup django project"
|
||||
$SETUP_COMMAND setup "${DJANGO_PATH}"
|
||||
echo "Collect static files"
|
||||
python3 "${DJANGO_PATH}/manage.py" collectstatic --noinput
|
||||
|
||||
cat <<E-O-H >> "${DJANGO_PATH}/${DJANGO_MAIN_MODULE}/settings.py"
|
||||
echo "Disable DEBUG mode"
|
||||
cat <<E-O-H >> "$DJANGO_SETTINGS_FILE"
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
DEBUG = False
|
||||
E-O-H
|
||||
|
||||
echo "Done"
|
||||
### end ###
|
||||
34
goss.yaml
Normal file
34
goss.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
command:
|
||||
/usr/sbin/httpd -t:
|
||||
exit-status: 0
|
||||
ps axo cmd | grep -q [w]sgi-daemon:
|
||||
exit-status: 0
|
||||
file:
|
||||
/run/httpd:
|
||||
exists: true
|
||||
mode: "0710"
|
||||
owner: apache
|
||||
group: apache
|
||||
filetype: directory
|
||||
/srv/application/django/main/wsgi.py:
|
||||
exists: true
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
filetype: file
|
||||
package:
|
||||
httpd:
|
||||
installed: true
|
||||
python3-mod_wsgi:
|
||||
installed: true
|
||||
port:
|
||||
tcp6:80:
|
||||
listening: true
|
||||
ip:
|
||||
- '::'
|
||||
process:
|
||||
httpd:
|
||||
running: true
|
||||
http:
|
||||
http://localhost:
|
||||
status: 200
|
||||
Reference in New Issue
Block a user