From e4f689ff8d10764d807f334fc59e54c244d88e54 Mon Sep 17 00:00:00 2001 From: clsr Date: Sun, 24 Nov 2019 03:14:32 +0100 Subject: Initial commit --- gomf-modpanel/Dockerfile | 31 +++++++++++++++++ gomf-modpanel/run-gomf-modpanel.bash | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 gomf-modpanel/Dockerfile create mode 100644 gomf-modpanel/run-gomf-modpanel.bash (limited to 'gomf-modpanel') diff --git a/gomf-modpanel/Dockerfile b/gomf-modpanel/Dockerfile new file mode 100644 index 0000000..8601629 --- /dev/null +++ b/gomf-modpanel/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:alpine AS builder + +RUN set -x \ + && apk add --no-cache git build-base file-dev \ + && git clone https://git.clsr.net/gomf/gomf-modpanel-web /gomf-modpanel-web \ + && rm -rf /gomf-modpanel-web/.git \ + && go get -v git.clsr.net/gomf/gomf-modpanel + + +FROM alpine + +RUN set -x \ + && apk add --no-cache libmagic bash + +COPY --from=builder /go/bin/gomf-modpanel /app/ +COPY --from=builder /gomf-modpanel-web /gomf-modpanel + +COPY run-gomf-modpanel.bash /app/ + +ARG UID=1000 +RUN set -x \ + && adduser -S -u $UID gomf \ + && mkdir -p /gomf/upload/ids /gomf/log \ + && chown -R gomf /gomf + +USER gomf +WORKDIR /gomf-modpanel +VOLUME /gomf/upload +VOLUME /gomf/log +EXPOSE 9001 +ENTRYPOINT ["bash", "/app/run-gomf-modpanel.bash"] diff --git a/gomf-modpanel/run-gomf-modpanel.bash b/gomf-modpanel/run-gomf-modpanel.bash new file mode 100644 index 0000000..bfa4385 --- /dev/null +++ b/gomf-modpanel/run-gomf-modpanel.bash @@ -0,0 +1,64 @@ +#!/bin/bash + +set -eu + +############################################################################### + +# The gomf-modpanel binary +GOMF_MODPANEL_BIN=/app/gomf-modpanel + +# Root folder for Gomf containing gomf-modpanel-web files +# +# Defaults to current directory if not set. +GOMF_MODPANEL_ROOT=/gomf-modpanel + +# Root folder for Gomf containing gomf-web files +# +# Defaults to current directory if not set. +GOMF_ROOT=/gomf + +# The host to listen on for HTTP and/or HTTPS +# +# Use 'localhost' if using local reverse proxy, 0.0.0.0 to listen to any host +# or a specific hostname to only allow connections to that address. +LISTEN_HOST=0.0.0.0 + +# The port to listen on for HTTP +# +# 80 for a standard HTTP server, probably a higher port (e.g. 9000) if +# reverse-proxied. +HTTP_PORT=9001 + +# The port to listen on for HTTPS +# +# 443 for a standard HTTPS server. Requires TLS_CERT and TLS_KEY +#HTTPS_PORT=8443 + +# SSL certificate for HTTPS +#TLS_CERT=cert.pem + +# SSL certificate key for HTTPS +#TLS_KEY=key.pem + +source /gomf-modpanel.conf + +############################################################################### + +flags=() +[ -n "${GOMF_MODPANEL_ROOT:-}" ] && cd "$GOMF_MODPANEL_ROOT" +[ -n "${GOMF_ROOT:-}" ] && flags+=(--gomf-root "$GOMF_ROOT") +[ -n "${URL_PREFIX:-}" ] && flags+=(--prefix "$URL_PREFIX") +[ -n "${DELETION_LOG:-}" ] && flags+=(--deletion-log "$DELETION_LOG") +[ -n "${UPLOAD_URL:-}" ] && flags+=(--upload-url "$UPLOAD_URL") +[ -n "${HTTP_PORT:-}" ] && flags+=(--http "${LISTEN_HOST:-localhost}:$HTTP_PORT") +[ -n "${HTTPS_PORT:-}" ] && [ -n "${TLS_CERT:-}" ] && [ -n "${TLS_KEY:-}" ] && flags+=( + --https "${LISTEN_HOST:-localhost}:$HTTPS_PORT" + --cert "$TLS_CERT" --key "$TLS_KEY") +oldifs="$IFS" IFS=, +[ -n "${ACCESS[*]:-}" ] && flags+=(--access "${ACCESS[*]}") +IFS="$oldifs" + +printf "%s" "${GOMF_MODPANEL_BIN:-gomf-modpanel}" +[ "${#flags}" -gt 0 ] && printf " \"%s\"" "${flags[@]}" +printf "\n" +exec "${GOMF_MODPANEL_BIN:-gomf-modpanel}" "${flags[@]}" -- cgit