From 9cbd7bd9d36a67c139eca8fae5d58f63d1de6d1a Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 13:07:21 -0700 Subject: [PATCH] Remove bash dependency Depending on bash wasn't strictly necessary, as the two minimal scripts in the repo were both nearly POSIX anyways. Aside from simplifying the repo's dependencies a little bit, this also helps reduce the overall Docker image size as an added bonus. --- Dockerfile | 15 +++++++++------ misc/tor/start-tor.sh | 2 +- run | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index c9f2f20..b6f6483 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,11 @@ RUN pip install --prefix /install --no-warn-script-location --no-cache-dir -r re FROM python:3.8-alpine -RUN apk add --update --no-cache tor curl bash openrc +RUN apk add --update --no-cache tor curl openrc # libcurl4-openssl-dev +RUN apk -U upgrade + ARG DOCKER_USER=whoogle ARG DOCKER_USERID=927 ARG config_dir=/config @@ -69,19 +71,20 @@ COPY app/ app/ COPY run . #COPY whoogle.env . -# Allow writing symlinks to build dir -RUN chown 102:102 app/static/build - # Create user/group to run as -RUN adduser -D -g $DOCKER_USERID -u $DOCKER_USERID $DOCKER_USER +RUN adduser -D -g $DOCKER_USERID -u $DOCKER_USERID $DOCKER_USER + # Fix ownership / permissions RUN chown -R ${DOCKER_USER}:${DOCKER_USER} /whoogle /var/lib/tor +# Allow writing symlinks to build dir +RUN chown $DOCKER_USERID:$DOCKER_USERID app/static/build + USER $DOCKER_USER:$DOCKER_USER EXPOSE $EXPOSE_PORT -HEALTHCHECK --interval=30s --timeout=5s \ +HEALTHCHECK --interval=30s --timeout=5s \ CMD curl -f http://localhost:${EXPOSE_PORT}/healthz || exit 1 CMD misc/tor/start-tor.sh & ./run diff --git a/misc/tor/start-tor.sh b/misc/tor/start-tor.sh index e29241f..7e7e282 100755 --- a/misc/tor/start-tor.sh +++ b/misc/tor/start-tor.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if [ "$(whoami)" != "root" ]; then tor -f /etc/tor/torrc diff --git a/run b/run index 9593201..2cc3cfe 100755 --- a/run +++ b/run @@ -1,11 +1,11 @@ -#!/bin/bash +#!/bin/sh # Usage: # ./run # Runs the full web app # ./run test # Runs the testing suite -set -euo pipefail +set -eu -SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +SCRIPT_DIR="$(CDPATH= command cd -- "$(dirname -- "$0")" && pwd -P)" # Set directory to serve static content from SUBDIR="${1:-app}" @@ -17,7 +17,7 @@ rm -f "$SCRIPT_DIR"/app/static/build/*.js rm -f "$SCRIPT_DIR"/app/static/build/*.css # Check for regular vs test run -if [[ "$SUBDIR" == "test" ]]; then +if [ "$SUBDIR" = "test" ]; then # Set up static files for testing rm -rf "$STATIC_FOLDER" ln -s "$SCRIPT_DIR/app/static" "$STATIC_FOLDER"