{"id":20549498,"url":"https://github.com/akullpp/deployment-python","last_synced_at":"2026-04-14T04:31:17.893Z","repository":{"id":204290770,"uuid":"711510433","full_name":"akullpp/deployment-python","owner":"akullpp","description":"Deployment scripts for Python, Docker, AWS, Kubernetes","archived":false,"fork":false,"pushed_at":"2023-10-29T14:05:19.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T05:33:16.202Z","etag":null,"topics":["aws","docker","kubernetes","pip-tools","python","ruff"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akullpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-29T13:48:04.000Z","updated_at":"2024-02-16T06:54:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ae18b25-5563-41df-9b2d-d5c1bdfa1980","html_url":"https://github.com/akullpp/deployment-python","commit_stats":null,"previous_names":["akullpp/deployment-python"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/akullpp/deployment-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akullpp%2Fdeployment-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akullpp%2Fdeployment-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akullpp%2Fdeployment-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akullpp%2Fdeployment-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akullpp","download_url":"https://codeload.github.com/akullpp/deployment-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akullpp%2Fdeployment-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31782736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","docker","kubernetes","pip-tools","python","ruff"],"created_at":"2024-11-16T02:18:13.809Z","updated_at":"2026-04-14T04:31:17.877Z","avatar_url":"https://github.com/akullpp.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deployment for Python\n\nOpinionated shell scripts for deploying Python.\n\nA lot is based on the repository name and therefore the `SLUG` environment variable. In the examples, you should assume that we have a repository named `foobar-service` and we didn't set `SLUG` by hand.\n\nBtw, use the excellent [ShellCheck](https://www.shellcheck.net/) to lint your scripts!\n\n## Build with\n\n- 3.12 \u003c= [Python](https://docs.python.org) \u003c 3.13\n\n- [Docker](https://docs.docker.com/)\n\n- [Kubernetes](https://kubernetes.io/docs/home/)\n\n- [AWS](https://docs.aws.amazon.com/)\n\n- [pip-tools](https://github.com/jazzband/pip-tools)\n\n- [ruff](https://docs.astral.sh/ruff/)\n\nHere's the explanation in order of recommended execution:\n\n## slug.sh\n\nA lot of things are derived from the repository's name, i.e. you either set the `SLUG` environment variable manually or you replace `\u003cREPLACE_WITH_REPOSITORY_NAME_ENV_VAR\u003e` with something provided by your CI/CD like `GITHUB_REPOSITORY_NAME`, `BITBUCKET_REPO_SLUG`, ...\n\nExample: `BITBUCKET_REPO_SLUG=foobar-service` will result in `SLUG=foobar`\n\n## master.sh\n\nSets up all the environment variables for a specific branch/environment, i.e. rename this file to `production.sh` or duplicate it for whatever environment you build for. It requires some replacements:\n\n- `\u003cREPLACE_WITH_AWS_ACCOUNT_ID\u003e`, e.g. 123456789012 or environment variable\n\n- `\u003cREPLACE_WIHT_AWS_REGION\u003e`, e.g. us-east-1 or environment variable\n\n- `\u003cREPLACE_WITH_API_URL_NAME\u003e`, e.g. api.foobar.com or environment variable\n\nThen we have the `CONTEXT` for our API which I like to base on the `SLUG`, e.g. `api.company.com/foobar` but you can also set it manually.\n\n## build.sh\n\nTriggers `make`, see `Makefile`, if you don't want to use pip-tools, change it.\n\n## lint.sh\n\nTriggers `make lint`, see `Makefile` for an example. If you don't use ruff, change it.\n\n## docker.sh\n\nHere we build the docker image and push it to the ECR repository. Have a look at the inlined Dockerfile, and change the `CMD` if you need something different from FastAPI.\n\nIt also requires some environment_variables to be set:\n\n- `SLUG`, set by `slug.sh` or manually, e.g. in `master.sh`\n\n- `\u003cREPLACE_WITH_BRANCH_NAME_ENV_VAR\u003e`, e.g. `GITHUB_REF##*/`, `BITBUCKET_BRANCH`, ...\n\n- `\u003cREPLACE_WITH_COMMIT_HASH_ENV_VAR\u003e`, e.g. `GITHUB_SHA`, `BITBUCKET_COMMIT`, ...\n\n- `AWS_ECR_URL`\n\n- `AWS_REGION`\n\n- `AWS_ACCESS_KEY_ID`\n\n- `AWS_SECRET_ACCESS_KEY`\n\nA multi-staged build follows that can use a specific `CONTEXT` (set in `master.sh`) environment variable for the server.\n\nThe images pushed assume an existing repository with `SLUG` as it's name, e.g. `foobar`.\n\nIt will push the image with the tags `latest` and branch name with shortened commit hash, e.g. `master-1234567`.\n\n## k8s.sh\n\nSo one assumption here is that `STAGE` is basically also your k8s namespace, e.g. `(STAGE=PRODUCTION) == (NAMESPACE=production)`.\n\nYet another assumption is that you've created a secret in the secrets-manager with name `$SLUG-secrets`, e.g. `foobar-secrets`.\n\nI use [envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) to replace variables in the `*.yml` files with environment variables.\n\nHave a look at the YAML files yourself, they provide a basic skeleton.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakullpp%2Fdeployment-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakullpp%2Fdeployment-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakullpp%2Fdeployment-python/lists"}