From 5b0cab4a4e401e9e606184b2d4e750f045d957c5 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Wed, 12 Jul 2023 07:53:09 +0200 Subject: [PATCH] add entryfile --- Dockerfile | 37 +++++++------------------------------ entrypoint.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 3dfaed1..1247c73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,40 +34,17 @@ ENV FILTER_FILE "/etc/tinyproxy/filter" RUN apk add --no-cache \ tinyproxy curl -RUN mv /etc/tinyproxy/tinyproxy.conf /etc/tinyproxy/tinyproxy.default.conf +RUN mv /etc/tinyproxy/tinyproxy.conf /etc/tinyproxy/tinyproxy.default.conf && \ + touch /etc/tinyproxy/tinyproxy.conf -RUN <> /etc/tinyproxy/tinyproxy.conf -User $TINYPROXY_UID -Group $TINYPROXY_GID -Port $PORT -Timeout $TIMEOUT -DefaultErrorFile "/usr/share/tinyproxy/default.html" - -StatHost "tinyproxy.stats" -StatFile "/usr/share/tinyproxy/stats.html" - -LogLevel $LOGLEVEL -MaxClients $MAXCLIENTS -ViaProxyName "tinyproxy" - -Filter "$FILTER_FILE" -FilterURLs Off -FilterCaseSensitive Off -FilterDefaultDeny Yes - -Allow 127.0.0.1/8 -Allow 10.0.0.0/8 - -EOF - -RUN set -eu && \ - CONFIG='/etc/tinyproxy/tinyproxy.conf' && \ - [ -z "$UPSTREAM_PROXY_FILE" ] || export UPSTREAM_PROXY=$(cat $UPSTREAM_PROXY_FILE) && \ - [ -z "$UPSTREAM_PROXY" ] || echo "upstream http $UPSTREAM_PROXY \".\"" >> "$CONFIG" +WORKDIR /swarmproxy +COPY entrypoint.sh entrypoint.sh RUN chown -R ${TINYPROXY_UID}:${TINYPROXY_GID} /etc/tinyproxy /var/log/tinyproxy + USER ${TINYPROXY_UID}:${TINYPROXY_GID} EXPOSE 8888 -ENTRYPOINT ["/usr/bin/tinyproxy", "-d"] +ENTRYPOINT ["/swarmproxy/entrypoint.sh"] +CMD ["/usr/bin/tinyproxy", "-d"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..563f184 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +set -e + +CONFIG = "/etc/tinyrpoxy/tinyproxy.conf" + +function writeConfig() { + cat << EOF >> "$CONFIG" +User $TINYPROXY_UID +Group $TINYPROXY_GID +Port $PORT +Timeout $TIMEOUT +DefaultErrorFile "/usr/share/tinyproxy/default.html" + +StatHost "tinyproxy.stats" +StatFile "/usr/share/tinyproxy/stats.html" + +LogLevel $LOGLEVEL +MaxClients $MAXCLIENTS +ViaProxyName "tinyproxy" + +Filter "$FILTER_FILE" +FilterURLs Off +FilterCaseSensitive Off +FilterDefaultDeny Yes + +Allow 127.0.0.1/8 +Allow 10.0.0.0/8 + +EOF +} + +function addUpstreamConfig() { + [ -z "$UPSTREAM_PROXY_FILE" ] || export UPSTREAM_PROXY=$(cat $UPSTREAM_PROXY_FILE) + [ -z "$UPSTREAM_PROXY" ] || echo "upstream http $UPSTREAM_PROXY \".\"" >> "$CONFIG" +} + +function main() { + writeConfig + addUpstreamConfig +} + +main $@