mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-10-04 22:05:45 +01:00
Fix tor (#145)
Add proper version in the container, and fix tor logging and inconsistent flag
This commit is contained in:
@@ -51,6 +51,8 @@ jobs:
|
||||
context: .
|
||||
target: cwa-bd
|
||||
push: true
|
||||
build-args: |
|
||||
BUILD_VERSION=$(date +'%Y%m%d')-${{ github.sha }}
|
||||
tags: ${{ steps.meta-main.outputs.tags }}
|
||||
labels: ${{ steps.meta-main.outputs.labels }}
|
||||
|
||||
@@ -82,6 +84,8 @@ jobs:
|
||||
context: .
|
||||
target: cwa-bd-tor
|
||||
push: true
|
||||
build-args: |
|
||||
BUILD_VERSION=$(date +'%Y%m%d')-${{ github.sha }}
|
||||
tags: ${{ steps.meta-tor.outputs.tags }}
|
||||
labels: ${{ steps.meta-tor.outputs.labels }}
|
||||
|
||||
|
||||
+5
-4
@@ -1,6 +1,10 @@
|
||||
# Use python-slim as the base image
|
||||
FROM python:3.10-slim AS base
|
||||
|
||||
# Add build argument for version
|
||||
ARG BUILD_VERSION
|
||||
ENV BUILD_VERSION=${BUILD_VERSION}
|
||||
|
||||
# Set shell to bash with pipefail option
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
@@ -107,7 +111,7 @@ CMD ["/app/entrypoint.sh"]
|
||||
|
||||
FROM base AS cwa-bd-tor
|
||||
|
||||
ENV ENABLE_TOR=true
|
||||
ENV USING_TOR=true
|
||||
|
||||
# Install Tor and dependencies
|
||||
RUN apt-get update && \
|
||||
@@ -119,8 +123,5 @@ RUN apt-get update && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Tor configuration is handled by entrypoint/script now or permissions set earlier
|
||||
# RUN chmod +x /app/tor.sh # This is removed as it's done in the base stage setup
|
||||
|
||||
# Override the default command to run Tor
|
||||
CMD ["/app/tor.sh"]
|
||||
|
||||
@@ -7,8 +7,8 @@ services:
|
||||
BOOK_LANGUAGE: en
|
||||
USE_BOOK_TITLE: true
|
||||
FLASK_DEBUG: false
|
||||
ENABLE_TOR: true
|
||||
TZ: America/New_York
|
||||
USING_TOR: true
|
||||
APP_ENV: prod
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
|
||||
@@ -9,6 +9,9 @@ echo "Starting entrypoint script"
|
||||
echo "Log file: $LOG_FILE"
|
||||
set -e
|
||||
|
||||
# Print build version
|
||||
echo "Build version: $BUILD_VERSION"
|
||||
|
||||
# Configure timezone
|
||||
if [ "$TZ" ]; then
|
||||
echo "Setting timezone to $TZ"
|
||||
|
||||
@@ -139,11 +139,3 @@ assert expected_sha256 == downloaded_sha256, f"Downloaded file SHA256 mismatch.
|
||||
print(f"Downloaded file SHA256 matches expected: {expected_sha256}")
|
||||
|
||||
print("--- E2E Test Completed Successfully ---")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
LOG_DIR=${LOG_ROOT:-/var/log/}/cwa-book-downloader
|
||||
mkdir -p $LOG_DIR
|
||||
LOG_FILE=${LOG_DIR}/cwa-bd_tor.log
|
||||
|
||||
exec 3>&1 4>&2
|
||||
exec > >(tee -a $LOG_FILE) 2>&1
|
||||
echo "Starting tor script"
|
||||
echo "Log file: $LOG_FILE"
|
||||
|
||||
set +x
|
||||
set -e
|
||||
|
||||
echo "Build version: $BUILD_VERSION"
|
||||
|
||||
echo "[*] Installing Tor and dependencies..."
|
||||
echo "[*] Writing Tor transparent proxy config..."
|
||||
|
||||
@@ -55,6 +68,7 @@ timeout 300 bash -c '
|
||||
|
||||
echo "[✓] Tor is ready."
|
||||
|
||||
sleep 5
|
||||
# Check if outgoing IP is using Tor
|
||||
echo "[*] Verifying Tor connectivity..."
|
||||
RESULT=$(pyrequests https://check.torproject.org/api/ip)
|
||||
@@ -73,10 +87,11 @@ fi
|
||||
# Then set the timezone
|
||||
|
||||
# Get timezone from IP
|
||||
TIMEZONE=$(pyrequests https://ipapi.co/timezone) ||
|
||||
TIMEZONE=$(pyrequests http://ip-api.com/line?fields=timezone) ||
|
||||
TIMEZONE=$(pyrequests http://worldtimeapi.org/api/ip | grep -oP '"timezone":"\K[^"]+') ||
|
||||
TIMEZONE=$(pyrequests https://ip2tz.isthe.link/v2 | grep -oP '"timezone": *"\K[^"]+') ||
|
||||
sleep 1
|
||||
TIMEZONE=$(pyrequests https://ipapi.co/timezone) || \
|
||||
TIMEZONE=$(pyrequests http://ip-api.com/line?fields=timezone) || \
|
||||
TIMEZONE=$(pyrequests http://worldtimeapi.org/api/ip | grep -oP '"timezone":"\K[^"]+') || \
|
||||
TIMEZONE=$(pyrequests https://ip2tz.isthe.link/v2 | grep -oP '"timezone": *"\K[^"]+') || \
|
||||
true
|
||||
|
||||
# If TIMEZONE is not set, use the default timezone
|
||||
|
||||
Reference in New Issue
Block a user