Skip to content

Commit

Permalink
Merge pull request #224 from NASA-IMPACT/fix/makefile-to-persist-cd
Browse files Browse the repository at this point in the history
Fix persistent  cd command line
  • Loading branch information
amarouane-ABDELHAK authored Aug 21, 2024
2 parents b1a3bd9 + 5bef391 commit 12a8030
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ SECRET_NAME=""
ENV_FILE=".env"
SM2A_FOLDER="sm2a"

CHDIR_SHELL := $(SHELL)
define chdir
$(eval _D=$(firstword $(1) $(@D)))
$(info $(MAKE): cd $(_D)) $(eval SHELL = cd $(_D); $(CHDIR_SHELL))
endef


important_message = \
Expand All @@ -32,45 +27,44 @@ count_down = \
test


all: switch-to-sm2a sm2a-local-init sm2a-local-run
all: sm2a-local-init sm2a-local-run

test:
pytest tests

switch-to-sm2a:
$(call chdir,${SM2A_FOLDER})

sm2a-local-run: switch-to-sm2a sm2a-local-stop sm2a-cp-dags
sm2a-local-run: sm2a-local-stop sm2a-cp-dags
@echo "Running SM2A"
cd ${SM2A_FOLDER} && \
docker compose up -d
$(call important_message, "Give the resources a minute to be healthy 💪")
$(count_down)
$(call info_message, "Please visit http://localhost:8080")
echo "username:airflow | password:airflow"
echo "To use local SM2A with AWS update ${SM2A_FOLDER}/sm2a-local-config/.env AWS credentials"

sm2a-local-init: switch-to-sm2a sm2a-cp-dags
cp sm2a-local-config/env_example sm2a-local-config/.env
docker compose run --rm airflow-cli db init
docker compose run --rm airflow-cli users create --email [email protected] --firstname airflow --lastname airflow --password airflow --username airflow --role Admin
sm2a-local-init: sm2a-cp-dags
cp ${SM2A_FOLDER}/sm2a-local-config/env_example ${SM2A_FOLDER}/sm2a-local-config/.env
docker compose -f ${SM2A_FOLDER}/docker-compose.yml run --rm airflow-cli db init
docker compose -f ${SM2A_FOLDER}/docker-compose.yml run --rm airflow-cli users create --email [email protected] --firstname airflow --lastname airflow --password airflow --username airflow --role Admin

sm2a-local-stop: switch-to-sm2a
docker compose down
sm2a-local-stop:
docker compose -f ${SM2A_FOLDER}/docker-compose.yml down

sm2a-cp-dags:
cp -r ../dags dags
cp -r dags ${SM2A_FOLDER}/.

sm2a-deploy: switch-to-sm2a sm2a-cp-dags
sm2a-deploy: sm2a-cp-dags
@echo "Installing the deployment dependency"
pip install -r deploy_requirements.txt
echo "Deploying SM2A"
python scripts/generate_env_file.py --secret-id ${SECRET_NAME} --env-file ${ENV_FILE}
./scripts/deploy.sh ${ENV_FILE} <<< init
cd ${SM2A_FOLDER} && \
pip install -r deploy_requirements.txt && \
echo "Deploying SM2A" && \
python ./scripts/generate_env_file.py --secret-id ${SECRET_NAME} --env-file ${ENV_FILE} && \
./scripts/deploy.sh ${ENV_FILE} <<< init && \
./scripts/deploy.sh ${ENV_FILE} <<< deploy

clean: switch-to-sm2a sm2a-local-stop
clean: sm2a-local-stop
@echo "Cleaning local env"
docker container prune -f
docker image prune -f
docker volume prune -f

0 comments on commit 12a8030

Please sign in to comment.