Skip to content

Commit 7257498

Browse files
authored
Merge pull request #8 from openstates/add-entrypoint-script
Add entrypoint
2 parents 71b05c3 + 613341a commit 7257498

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ RUN poetry install --no-root \
3232

3333
# Copy application code
3434
COPY . /app
35+
# Copy entrypoint script
36+
COPY entrypoint.sh /entrypoint.sh
37+
RUN chmod +x /entrypoint.sh
3538

36-
ENTRYPOINT ["poetry", "run", "python", "main.py"]
39+
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Handle GCP credentials
5+
if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then
6+
echo "Applying app credentials..."
7+
echo "${GOOGLE_APPLICATION_CREDENTIALS}" > /creds.json
8+
export GOOGLE_APPLICATION_CREDENTIALS="/creds.json"
9+
elif [[ -n "${GOOGLE_CREDENTIAL_FILE}" ]]; then
10+
echo "Assuming a valid credentials file is mounted at ${GOOGLE_CREDENTIAL_FILE}..."
11+
export GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_CREDENTIAL_FILE}
12+
fi
13+
14+
# Run the main app
15+
exec poetry run python main.py "$@"

utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def init_duckdb(
9090
relative_path = jurisdiction.replace("ocd-jurisdiction/", "")
9191
sub_directory = f"**/{relative_path}/{DAG_RUN_START}"
9292
else:
93-
sub_directory = "**"
93+
sub_directory = "*/**"
9494

9595
# Create DuckDB and load
9696
logger.info("Creating DuckDB schema and loading data...")
@@ -107,7 +107,9 @@ def init_duckdb(
107107
"No file found in local directory, attempting to download from GCS, requires credentials in ENV."
108108
)
109109
# Remove "**/" from path prefix before passing to GCS downloader
110-
gcs_path = sub_directory[3:] if sub_directory.startswith("**/") else sub_directory
110+
gcs_path = (
111+
sub_directory[3:] if sub_directory.startswith("**/") else sub_directory
112+
)
111113
download_files_from_gcs(gcs_path)
112114

113115
# Load data into duckdb table

0 commit comments

Comments
 (0)