diff --git a/backend/Dockerfile.pe b/backend/Dockerfile.pe index b668501d7..b092d4656 100644 --- a/backend/Dockerfile.pe +++ b/backend/Dockerfile.pe @@ -19,10 +19,25 @@ RUN pip3.10 install --upgrade pip RUN apt remove dav1d && apt autoclean && apt autoremove +# Install AWS CLI +RUN curl --insecure "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" +RUN unzip awscliv2.zip +RUN ./aws/install + # Install pe-source module # Sync the latest from cf-staging branch -RUN git clone -b cf-source-staging https://github.com/cisagov/pe-reports.git && cd pe-reports && git checkout c9cbbd73b22ef38cabe1da6ba50aeb2dc0be4f99 && pip install . +RUN git clone -b AL-staging-SQS https://github.com/cisagov/pe-reports.git && \ + cd pe-reports && \ + git checkout 6dcd017551ba14022e110c073e1bdbc804c795f8 && \ + pip install . + +RUN python -m spacy download en_core_web_lg + +# Create database.ini +RUN echo "[database]" > database.ini \ + && echo "user=$(cat db_user.txt)" >> database.ini \ + && echo "password=$(cat db_password.txt)" >> database.ini COPY worker worker -CMD ["./worker/pe-worker-entry.sh"] +CMD ["./worker/generate_config.sh", "./worker/pe-worker-entry.sh"] diff --git a/backend/worker/generate_config.sh b/backend/worker/generate_config.sh new file mode 100755 index 000000000..3791d5f24 --- /dev/null +++ b/backend/worker/generate_config.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Generate database.ini +cat < pe-reports/src/pe_reports/data/database.ini +[postgres] +host=$(DB_HOST) +database=$(PE_DB_NAME) +user=$(PE_DB_USERNAME) +password=$(PE_DB_PASSWORD) +port=5432 + +[shodan] +key1=$(PE_SHODAN_API_KEYS) + +[staging] +[cyhy_mongo] +[sixgill] +[whoisxml] +key= +[intelx] +[dnsmonitor] +[pe_db_password_key] +[blocklist] +[dehashed] +[dnstwist] +[hibp] +[API_Client_ID] +[API_Client_secret] +[API_WHOIS] +[pe_api] + +EOF + +# Find the path to the pe_reports package in site-packages +pe_reports_path=$(pip show pe-reports | grep -E '^Location:' | awk '{print $2}') + +# Ensure pe_reports_path ends with /pe_reports +pe_reports_path="${pe_reports_path%/pe-reports}/pe_reports" + + +# Copy database.ini to the module's installation directory +cp /app/pe-reports/src/pe_reports/data/database.ini "${pe_reports_path}/data/" + +exec "$@" \ No newline at end of file