Adds entrypoint #6

Merged
OCram85 merged 4 commits from entrypoint into main 2023-07-12 10:55:59 +02:00
2 changed files with 34 additions and 10 deletions
Showing only changes of commit c009f5646b - Show all commits

View File

@ -37,14 +37,15 @@ RUN apk add --no-cache \
RUN mv /etc/tinyproxy/tinyproxy.conf /etc/tinyproxy/tinyproxy.default.conf && \
touch /etc/tinyproxy/tinyproxy.conf
COPY entrypoint.sh /swarmproxy/entrypoint.sh
WORKDIR /swarmproxy
COPY entrypoint.sh entrypoint.sh
RUN chown -R ${TINYPROXY_UID}:${TINYPROXY_GID} /etc/tinyproxy /var/log/tinyproxy
RUN chown -R ${TINYPROXY_UID}:${TINYPROXY_GID} /etc/tinyproxy /var/log/tinyproxy /swarmproxy && \
chmod +x /swarmproxy/entrypoint.sh
USER ${TINYPROXY_UID}:${TINYPROXY_GID}
EXPOSE 8888
ENTRYPOINT ["/swarmproxy/entrypoint.sh"]
CMD ["/usr/bin/tinyproxy", "-d"]
CMD ["-d"]

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -e
CONFIG = "/etc/tinyrpoxy/tinyproxy.conf"
CONFIG="/etc/tinyproxy/tinyproxy.conf"
function writeConfig() {
cat << EOF >> "$CONFIG"
@ -19,11 +19,6 @@ 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
@ -35,9 +30,37 @@ function addUpstreamConfig() {
[ -z "$UPSTREAM_PROXY" ] || echo "upstream http $UPSTREAM_PROXY \".\"" >> "$CONFIG"
}
function addFilterConfig() {
if [ -f "$FILTER_FILE" ]; then
cat << FBLOCK >> "$CONFIG"
Filter "$FILTER_FILE"
FilterURLs Off
FilterCaseSensitive Off
FilterDefaultDeny Yes
FBLOCK
else
echo "🦁 FILTER_FILE not found or set."
fi
}
function showConfig() {
echo "🦁 Final Swarmproxy config 🦁"
cat "$CONFIG"
}
function execTinyproxy() {
echo "🦁 Starting Tinyproxy..."
echo "args count: $#"
echo "args: $@"
exec "/usr/bin/tinyproxy" "$@"
}
function main() {
writeConfig
addUpstreamConfig
addFilterConfig
showConfig
execTinyproxy $@
}
main $@