diff --git a/Dockerfile b/Dockerfile index 90f58c3..cc8cd21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,9 @@ COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt RUN apt-get update -y && apt-get upgrade -y -RUN apt-get install -y rsync +RUN apt-get install -y rsync ssh + +# TODO: Need to install ssh key here COPY . ./ diff --git a/basketwatch.py b/basketwatch.py index df53610..3acd829 100755 --- a/basketwatch.py +++ b/basketwatch.py @@ -24,7 +24,12 @@ def requestsync(): try: # Run rsync print("Sync requested... running now.") - subprocess.run(['rsync', '-ravzL', REMOTE_DIRECTORY, LOCAL_DEST], check=True) + subprocess.run(['rsync', + '-ravzL', + '-e', + 'ssh -i /root/.ssh/id_rsa', + REMOTE_DIRECTORY, + LOCAL_DEST], check=True) return jsonify({'status': 'OK'}) except subprocess.CalledProcessError as e: return jsonify({"error": 'rsync failed', 'details': str(e)}), 500 diff --git a/docker-compose.yml b/docker-compose.yml index f13b9a6..882d9b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,6 @@ services: - "35350:35350" volumes: - /serve/data/basket:/serve/data/basket - - $HOME/.ssh:/root/.ssh environment: - UID=${UID:-1000} - GID=1000 diff --git a/setupkeys.sh b/setupkeys.sh new file mode 100644 index 0000000..8d023fb --- /dev/null +++ b/setupkeys.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -u -e -o pipefail + +mkdir -p keys +ssh-keygen -f keys/id_rsa -t rsa + +ssh-copy-id -i keys/id_rsa sinbad@margarita