diff --git a/Dockerfile b/Dockerfile index 8af2fc4..1cc998a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,21 @@ -FROM alpine AS builder +FROM docker.io/library/httpd:2.4-alpine3.18 AS builder + +RUN apk --no-cache add \ + build-base \ + m4 \ + markdown -RUN apk --no-cache add build-base m4 markdown COPY . /src -RUN make -C /src DESTDIR=/tanks install +RUN make -C /src DESTDIR=/tanks && \ + make -C /src DESTDIR=/tanks install -FROM neale/eris -COPY --from=builder /tanks /tanks -CMD [ "/tanks/bin/go.sh" ] +# dos2unix src/go.sh src/rank.awk src/round.sh src/summary.awk && \ + + +FROM docker.io/library/httpd:2.4-alpine3.18 +COPY --from=builder /tanks/bin /tanks/bin +COPY --from=builder /tanks/www /tanks/www-orig +COPY httpd.conf /usr/local/apache2/conf/httpd.conf +#RUN sed -i 's/\/usr\/local\/apache2\/htdocs/\/tanks\/www/' /usr/local/apache2/conf/httpd.conf && \ +# sed -i 's/Options Indexes FollowSymLinks/Options Indexes FollowSymLinks ExecCGI\n AddHandler cgi-script .cgi\n SetEnv BASE_PATH \/tanks\/tanks\//' /usr/local/apache2/conf/httpd.conf +CMD [ "sh", "-c", "if [[ ! -d /tanks/www/ ]]; then mkdir /tanks/www/; fi && cp -ru /tanks/www-orig/* /tanks/www/ & /tanks/bin/go.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index cf2406b..0a1e94f 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ install: $(BINARIES) $(HTML) install summary.awk $(DESTDIR)/bin install forftanks $(DESTDIR)/bin - install -d -o $(id -u www) -g $(id -g www) $(DESTDIR)/www + install -d -o $(shell id -u www-data) -g $(shell id -g www-data) $(DESTDIR)/www install upload.cgi $(DESTDIR)/www install -m 0644 $(HTML) $(DESTDIR)/www install -m 0644 $(WWW) $(DESTDIR)/www diff --git a/go.sh b/go.sh index 74e6587..b803bef 100644 --- a/go.sh +++ b/go.sh @@ -1,14 +1,16 @@ -#! /bin/sh +#!/bin/sh cd $(dirname $0)/../www +export BASE_PATH=/tanks/www/state/ + ( - s6-tcpserver -u $(id -u www) -g $(id -g www) 0.0.0.0 80 /usr/bin/eris -c -. + httpd-foreground ) & ( while true; do - ../bin/round.sh */ + ../bin/round.sh /tanks/www/state/* sleep 60 done ) & diff --git a/httpd.conf b/httpd.conf new file mode 100644 index 0000000..2a3fb2f --- /dev/null +++ b/httpd.conf @@ -0,0 +1,38 @@ +ServerRoot "/usr/local/apache2" + +Listen 80 + +LoadModule mpm_event_module modules/mod_mpm_event.so +LoadModule unixd_module modules/mod_unixd.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule mime_module modules/mod_mime.so +LoadModule env_module modules/mod_env.so +LoadModule cgid_module modules/mod_cgid.so +LoadModule log_config_module modules/mod_log_config.so + + + User www-data + Group www-data + + + + AllowOverride none + Require all denied + + +DocumentRoot "/tanks/www" + + Options Indexes FollowSymLinks ExecCGI + AddHandler cgi-script .cgi + PassEnv BASE_PATH + + Require all granted + + + + LogFormat "%h %l %u %t \"%r\" %>s %b" common + CustomLog /dev/stdout common + + +LogLevel warn +ErrorLog /dev/stderr diff --git a/round.sh b/round.sh index 5136bca..f269323 100755 --- a/round.sh +++ b/round.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh if [ "$#" -gt 0 ]; then tanks="$@" diff --git a/upload.cgi.c b/upload.cgi.c index d3e4a70..f2e9ab0 100644 --- a/upload.cgi.c +++ b/upload.cgi.c @@ -285,7 +285,8 @@ main(int argc, char *argv[]) snprintf(path, sizeof(path), "%s%s/", BASE_PATH, token); if (-1 == stat(path, &st)) - return croak(422, "Invalid token"); + //return croak(422, "Invalid token"); + return croak(422, path); if (!S_ISDIR(st.st_mode)) return croak(422, "Invalid token"); for (i = 0; entries[i].name; i += 1) {