Skip to content

Commit

Permalink
Add bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Jul 2, 2024
1 parent 069e104 commit 560b97b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,13 @@ COPY ./README.md ./README.md
RUN python -m pip install --upgrade pip setuptools \
&& python -m pip install .

# Set env variables
ENV IGNORE_EXPERIMENTAL_WARNINGS=1
RUN mkdir persist
ENV DAGSTER_HOME=/popgetter-prod/persist
ENV DAGSTER_MODULE_NAME=popgetter
ENV ENV=prod
ENV AZURE_STORAGE_ACCOUNT=popgetter
ENV AZURE_CONTAINER=prod
# This doesn't work
# ENV AZURE_DIRECTORY=$(python -c 'import popgetter; print(popgetter.__version__)' 2>/dev/null)
ENV AZURE_DIRECTORY=0.1.0
ENV POPGETTER_COUNTRIES=bel,gb_nir

# TODO: Not the safest!
ARG SAS_TOKEN
RUN [ -z "$SAS_TOKEN" ] && echo "SAS_TOKEN build arg is required" && exit 1 || true
ENV SAS_TOKEN=$SAS_TOKEN

ENTRYPOINT ["/bin/bash"]
CMD ["-c", "python -m popgetter.run all"]
ARG POPGETTER_COUNTRIES
ENV POPGETTER_COUNTRIES=$POPGETTER_COUNTRIES

COPY ./deploy.sh ./deploy.sh
ENTRYPOINT ["./deploy.sh"]
38 changes: 38 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e

if [ -z "$ENV" ]; then
echo "ENV environment variable not set; must be either 'dev' or 'prod'"
exit 1
fi

if [ -z "$POPGETTER_COUNTRIES" ]; then
echo "POPGETTER_COUNTRIES environment variable not set; must be comma-separated list of country IDs"
exit 1
fi

export IGNORE_EXPERIMENTAL_WARNINGS=1
export DAGSTER_MODULE_NAME=popgetter
export DAGSTER_HOME=$(mktemp -d)
touch $DAGSTER_HOME/dagster.yaml # Silences Dagster warnings

echo "Relevant environment variables:"
echo " - POPGETTER_COUNTRIES: $POPGETTER_COUNTRIES"
echo " - ENV: $ENV"
if [ $ENV == "prod" ]; then
export AZURE_STORAGE_ACCOUNT=popgetter
export AZURE_CONTAINER=prod
export AZURE_DIRECTORY=$(python -c 'import popgetter; print(popgetter.__version__)' 2>/dev/null)
if [ -z "$SAS_TOKEN" ]; then
echo "SAS_TOKEN environment variable not set; it is required for Azure deployments"
exit 1
else
echo " - SAS_TOKEN: (exists)"
fi
echo " - AZURE_STORAGE_ACCOUNT: $AZURE_STORAGE_ACCOUNT"
echo " - AZURE_CONTAINER: $AZURE_CONTAINER"
echo " - AZURE_DIRECTORY: $AZURE_DIRECTORY"
fi

echo "Generating popgetter data. This may take a while."
python -m popgetter.run all

0 comments on commit 560b97b

Please sign in to comment.