From 70e5ddc3f2d16dfd444fe573c1433effc6ba1aff Mon Sep 17 00:00:00 2001 From: hankhill19580 Date: Tue, 6 Oct 2020 03:49:18 +0000 Subject: [PATCH] add a gitignore, add some more important things to gitignore, make it so setup_venv.sh works on future Debian versions, add Dockerfile and lighttpd.conf file for running a news server in a container --- .gitignore | 6 +++++ .mtn-ignore | 3 +++ Dockerfile | 9 ++++++++ lighttpd.docker.conf | 52 ++++++++++++++++++++++++++++++++++++++++++++ setup_venv.sh | 6 ++++- 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 lighttpd.docker.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ad8e73 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +^build +^env +^etc/.*.custom +# Accidentally checking in a working transifexrc would be extremely bad! +.transifexrc +^logs diff --git a/.mtn-ignore b/.mtn-ignore index 711c575..4ad8e73 100644 --- a/.mtn-ignore +++ b/.mtn-ignore @@ -1,3 +1,6 @@ ^build ^env ^etc/.*.custom +# Accidentally checking in a working transifexrc would be extremely bad! +.transifexrc +^logs diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f5b970a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine +RUN apk update +RUN apk add lighttpd +COPY build /var/www/localhost/htdocs/news +COPY lighttpd.docker.conf /etc/lighttpd/lighttpd.conf +RUN mkdir -p /run/lighttpd/ && \ + chown -R lighttpd /run/lighttpd +USER lighttpd +CMD lighttpd -f /etc/lighttpd/lighttpd.conf -D diff --git a/lighttpd.docker.conf b/lighttpd.docker.conf new file mode 100644 index 0000000..6b5bda5 --- /dev/null +++ b/lighttpd.docker.conf @@ -0,0 +1,52 @@ + +var.basedir = "/var/www/localhost" +var.logdir = "/var/log/lighttpd" +var.statedir = "/var/lib/lighttpd" + +server.port = 3000 + +server.modules = ( + "mod_rewrite", + "mod_access", + "mod_accesslog" +) + +#include "mime-types.conf" + + +mimetype.assign += ( ".su3" => "application/octet-stream", + ".xml" => "text/xml", + ".html" => "text/html", + ".txt" => "text/plain", ) + +server.username = "lighttpd" +server.groupname = "lighttpd" + +server.document-root = var.basedir + "/htdocs" +server.pid-file = "/run/lighttpd/lighttpd.pid" + +server.errorlog = var.logdir + "/error.log" + +server.indexfiles = ("index.php", "index.html", + "index.htm", "default.htm") +server.follow-symlink = "enable" + +static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi") + +accesslog.filename = var.logdir + "/access.log" + +dir-listing.activate = "enable" + +url.access-deny = ("~", ".inc") + +url.rewrite-repeat = ( + "^/news/news.atom.xml\?lang=([a-z]+(_[A-Za-z]+)?)" => "/news/news_$1.atom.xml", + "^/news/news.su3\?lang=([a-z]+(_[A-Za-z]+)?)" => "/news/news_$1.su3", +) + +url.rewrite-repeat-if-not-file = ( + "^/news/news_([a-z]+)_[A-Za-z]+.atom.xml" => "/news/news_$1.atom.xml", + "^/news/news_([a-z]+)_[A-Za-z]+.su3" => "/news/news_$1.su3", + "^/news/news_[a-z]+.atom.xml" => "/news/news.atom.xml", + "^/news/news_[a-z]+.su3" => "/news/news.su3", +) diff --git a/setup_venv.sh b/setup_venv.sh index e58e679..6897245 100755 --- a/setup_venv.sh +++ b/setup_venv.sh @@ -7,7 +7,11 @@ if [ ! $venv ]; then exit 1 else if [ ! -d $venv_dir ] ; then - $venv --distribute $venv_dir + if $venv --version | grep '[2-9][0-9].0.*'; then + $venv $venv_dir + else + $venv --distribute $venv_dir + fi fi . $venv_dir/bin/activate