con un clic
deploy-commands
// Generate deployment commands for a production go-fastapi instance
// Generate deployment commands for a production go-fastapi instance
You are generating a complete set of copy-pasteable bash commands to deploy go-fastapi to production.
Perform ALL of the following checks before generating any commands:
Ask the user for:
/home/user/secrets/go-aws-credentials)/home/user/secrets/ssh-keys/)Do NOT proceed without these.
Run: docker ps -a --filter name=^go-fastapi$ --format '{{.Names}}'
go-fastapi is returned: this is a resuming session (Path B)If a version was provided as argument $1, use it. Otherwise:
gh release list --repo geneontology/go-fastapi --limit 1gh api repos/geneontology/go-fastapi/compare/v{latest}...main --jq '.ahead_by'Check if the target version's Docker image exists:
docker manifest inspect geneontology/go-fastapi:{version_without_v} 2>/dev/null
If a date was provided as argument $2, use it. Otherwise use today's date in YYYY-MM-DD format.
Read these files to get the current placeholder names (these are the source of truth):
provision/production/backend.tf.sampleprovision/production/config-instance.yaml.sampleprovision/production/config-stack.yaml.sampleUse the gathered context to produce the full command set. Clearly separate commands by where they run:
gh release create v{VERSION} --target main --generate-notes --repo geneontology/go-fastapi
Then tell the user to wait for the Docker build workflow to complete and provide a command to check:
gh run list --repo geneontology/go-fastapi --workflow docker-build.yaml --limit 1
Generate commands for:
docker run to create the containerdocker cp to copy credentials and SSH keys from host into container at /tmp/chmod 600 /tmp/go-ssh*git clone, cd go-fastapi/provisioncp backend.tf.sample, sed to replace placeholder, go-deploy -initcp config-instance.yaml.sample, sed commands for each placeholdergo-deploycp config-stack.yaml.sample, sed commands for each placeholdergrep -rn 'REPLACE_ME_' config-stack.yaml config-instance.yaml aws/backend.tfexport ANSIBLE_HOST_KEY_CHECKING=False, go-deployGenerate commands for:
docker start + docker exec to rejoin the containercd /tmp/go-fastapi/provision, git pullgo-deploy --working-directory aws -list-workspaces -verbosesed -i for placeholder substitution, not emacs-dry-run, -verbose, -show, -output (NOT --dry-run)go-api-production-YYYY-MM-DDfastapi_tag is the version WITHOUT the leading "v"fastapi and apache_fastapi/code