diff --git a/Dockerfile b/Dockerfile index 4d7eff6..50b4f64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.14 AS build +FROM casjaysdevdocker/python2:latest AS build WORKDIR /tmp/build @@ -50,18 +50,17 @@ LABEL \ maintainer="CasjaysDev " COPY --from=build /usr/local/share/cherokee/. /usr/local/share/cherokee/ -COPY ./config/. /config/ -COPY ./data/. /data/ COPY ./bin/. /usr/local/bin/ - +COPY ./data/. /usr/local/share/template-files/data/ +COPY ./config/. /usr/local/share/template-files/config/ ENV PHP_SERVER=cherokee WORKDIR /data/htdocs -EXPOSE 80 19070 +EXPOSE 19070 19071 -VOLUME [ "/data", "/config", "/etc/ssl" ] +VOLUME [ "/data", "/config" ] ENTRYPOINT [ "tini", "--" ] HEALTHCHECK --interval=15s --timeout=3s CMD [ "/usr/local/bin/entrypoint-cherokee.sh" "healthcheck" ] diff --git a/bin/cherokee-server b/bin/cherokee-server new file mode 100644 index 0000000..ddbf35b --- /dev/null +++ b/bin/cherokee-server @@ -0,0 +1,33 @@ +#!/usr/bin/env sh +export PATH="/usr/local/share/cherokee/bin:$PATH" +[ -f "/config/ssl.env" ] && . "/config/ssl.env" + +if [ ! -d "/config/cherokee" ] && [ -d "/usr/local/share/template-files/config/cherokee" ]; then + mkdir -p "/config/cherokee" + cp -Rf "/usr/local/share/template-files/config/cherokee/." "/config/cherokee/" +fi + +[ -d "/data/htdocs" ] || mkdir -p "/data/htdocs" +[ -d "/data/htdocs/www" ] || cp -Rf "/usr/local/share/template-files/data/." "/data/" +[ -d "/usr/lib/cgi-bin" ] && [ -d "" ] && cp -Rf "/usr/lib/cgi-bin/." "/data/htdocs/cgi-bin/" +[ -f "/config/cherokee/cherokee.conf" ] && cp -Rfv "/config/cherokee/cherokee.conf" "/etc/cherokee/" +[ -d "/usr/local/share/cherokee/icons" ] && [ ! -d "/config/cherokee/icons" ] && cp -Rf "/usr/local/share/cherokee/icons/." "/config/cherokee/icons/" +[ -d "/usr/local/share/cherokee/themes" ] && [ ! -d "/config/cherokee/themes" ] && cp -Rf "/usr/local/share/cherokee/themes/." "/config/cherokee/themes/" + +if [ ! -f "/config/ssl/key.pem" ] || [ ! -f "/etc/ssl/crt.pem" ]; then + openssl req \ + -new \ + -newkey rsa:4096 \ + -days 3650 \ + -nodes \ + -x509 \ + -subj "/C=US/ST=CA/L=Manhattan\ Beach/O=Managed\ Kaos/OU=Cherokee\ SSL/CN=localhost" \ + -keyout /etc/ssl/server.pem \ + -out /etc/ssl/server.pem +fi + +if [ ! -f "/tmp/cherokee.pid" ]; then + cherokee-admin -b -p 19070 -c /config/cherokee.conf & + exec cherokee -c /etc/cherokee/cherokee.conf +fi + diff --git a/config/cherokee.conf b/config/cherokee/cherokee.conf similarity index 97% rename from config/cherokee.conf rename to config/cherokee/cherokee.conf index 744f7d1..5e3e531 100644 --- a/config/cherokee.conf +++ b/config/cherokee/cherokee.conf @@ -6,18 +6,18 @@ server!ipv6 = 1 server!keepalive = 1 server!keepalive_max_requests = 500 server!panic_action = /usr/bin/cherokee-panic -server!pid_file = /var/run/cherokee.pid +server!pid_file = /tmp/cherokee.pid server!server_tokens = full server!timeout = 15 server!tls = libssl server!tls!protocol!SSLv3 = 0 vserver!1!directory_index = index.html vserver!1!document_root = /data/htdocs/www -vserver!1!error_writer!filename = /var/log/cherokee.error +vserver!1!error_writer!filename = /dev/stderr vserver!1!error_writer!type = file vserver!1!logger = combined vserver!1!logger!access!buffsize = 16384 -vserver!1!logger!access!filename = /var/log/cherokee.access +vserver!1!logger!access!filename = /dev/stdout vserver!1!logger!access!type = file vserver!1!nick = default vserver!1!rule!5!encoder!gzip = allow @@ -25,11 +25,11 @@ vserver!1!rule!5!handler = server_info vserver!1!rule!5!handler!type = just_about vserver!1!rule!5!match = directory vserver!1!rule!5!match!directory = /about -vserver!1!rule!4!document_root = /usr/lib/cgi-bin +vserver!1!rule!4!document_root = /data/htdocs/cgi-bin vserver!1!rule!4!handler = cgi vserver!1!rule!4!match = directory vserver!1!rule!4!match!directory = /cgi-bin -vserver!1!rule!3!document_root = /usr/local/share/cherokee/themes +vserver!1!rule!3!document_root = /config/cherokee/themes vserver!1!rule!3!handler = file vserver!1!rule!3!match = directory vserver!1!rule!3!match!directory = /cherokee_themes @@ -40,8 +40,8 @@ vserver!1!rule!2!match!directory = /cherokee_icons vserver!1!rule!1!handler = common vserver!1!rule!1!handler!iocache = 1 vserver!1!rule!1!match = default -vserver!1!ssl_certificate_file = /etc/ssl/server.pem -vserver!1!ssl_certificate_key_file = /etc/ssl/server.pem +vserver!1!ssl_certificate_file = /config/ssl/server.pem +vserver!1!ssl_certificate_key_file = /config/ssl/server.pem icons!default = page_white.png icons!directory = folder.png icons!file!bomb.png = core @@ -298,3 +298,4 @@ mime!video/x-msvideo!extensions = avi mime!video/x-sgi-movie!extensions = movie mime!x-conference/x-cooltalk!extensions = ice mime!x-world/x-vrml!extensions = vrm,vrml,wrl + diff --git a/data/cgi-bin/.gitkeep b/data/htdocs/cgi-bin/.gitkeep similarity index 100% rename from data/cgi-bin/.gitkeep rename to data/htdocs/cgi-bin/.gitkeep