This repository has been archived on 2024-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
python-azure-example/justfile

52 lines
1.3 KiB
Makefile
Raw Normal View History

2024-03-01 14:11:34 +00:00
# Always use devbox environment to run commands.
set shell := ["devbox", "run"]
# Load dotenv
set dotenv-load
export TF_VAR_name := env("APP_NAME")
2024-03-01 21:05:49 +00:00
export GIT_SHA := `git rev-parse --short HEAD`
2024-03-01 14:11:34 +00:00
# Run server locally
run:
2024-03-01 21:05:49 +00:00
initdb --username=postgres || true
devbox services start postgresql
python src/app.py
run-docker:
docker build -t local/${APP_NAME}:${GIT_SHA} .
docker run -it --rm -p 8080:8080 local/${APP_NAME}:${GIT_SHA}
2024-03-01 14:11:34 +00:00
dependencies:
pip install -r src/requirements.txt
dependencies-lock:
pip freeze -l > src/requirements.txt
2024-03-01 21:05:49 +00:00
release:
#!/bin/env bash
USERNAME="00000000-0000-0000-0000-000000000000"
REGISTRY=$(terraform -chdir=terraform output -raw container_registry_name)
TAG=${REGISTRY}.azurecr.io/develop:${GIT_SHA}-$(date +"%F-%H-%M-%S")
docker build -t ${TAG} .
2024-03-01 14:11:34 +00:00
2024-03-01 21:05:49 +00:00
# For podman support we must use this hacks,
# otherwise az acr login would also do the docker login.
docker login \
--username=${USERNAME} \
--password=$(az acr login --name ${REGISTRY} --expose-token 2>/dev/null | jq -r '.accessToken') \
"${REGISTRY}.azurecr.io"
docker push ${TAG}
echo "Image pushed to ${TAG}"
echo "Modify your .env with TF_VAR_image=${TAG}"
deploy:
2024-03-01 14:11:34 +00:00
terraform -chdir=terraform init
terraform -chdir=terraform apply
2024-03-01 21:05:49 +00:00
destroy:
2024-03-01 14:11:34 +00:00
terraform -chdir=terraform destroy