### Install AppPack CLI with Homebrew Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/set-up/install.md This snippet provides commands to install the AppPack CLI using Homebrew. It first taps the official AppPack Homebrew repository and then installs the `apppack` package. ```bash brew tap apppackio/apppack brew install apppack ``` -------------------------------- ### Configure AppPack for Dockerfile Builds Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/dockerfile-builds.md Example `apppack.toml` configuration to specify 'dockerfile' as the build system and define a single web service with its start command. This is the minimum configuration required to enable Dockerfile builds. ```toml [build] system = "dockerfile" [services.web] command = "npm start" ``` -------------------------------- ### Authenticate AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/set-up/install.md After installing the AppPack CLI, use this command to authenticate your local client with the AppPack service. This will typically open a browser for login. ```bash apppack auth login ``` -------------------------------- ### Install AppPack Required Commands in Dockerfile Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/dockerfile-builds.md Examples of Dockerfile commands to install necessary utilities for AppPack compatibility in common minimal base images. These commands ensure that tools like `shell` can run within your final container. ```Dockerfile RUN apt-get update && apt-get install -y --no-install-recommends procps ``` ```Dockerfile RUN apk add --no-cache bash ``` -------------------------------- ### Create AppPack Cluster Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/initial-setup.md Initiates the creation of a new cluster for deploying applications. This command prompts for confirmation of the region, Docker Hub username and access token, and the chosen domain. The process creates necessary AWS resources and typically takes about 10 minutes. ```shell apppack create cluster ``` -------------------------------- ### Verify AppPack CLI Administrator Setup Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/initial-setup.md Verifies that the user is set up as an administrator by listing associated accounts. The user's AWS account should be visible in the output. ```shell apppack auth accounts ``` -------------------------------- ### Define Web and Worker Services with Procfile Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apps.md This `Procfile` example demonstrates how to define two distinct services for an AppPack application: a `web` service for handling HTTP traffic using Gunicorn, and a `worker` service for background tasks using Celery. Each service runs in an independent container and can be scaled separately. The `web` service is mandatory and connects to the load balancer, receiving the `PORT` environment variable. ```yaml web: gunicorn --bind=0.0.0.0:$PORT myapp:application worker: celery --app myapp.celery.app worker ``` -------------------------------- ### Authenticate AppPack CLI Login Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/initial-setup.md Authenticates the AppPack CLI, allowing users to log in or create a new account. If logging in with an email address and password, email verification is required before continuing. ```shell apppack auth login ``` -------------------------------- ### Verify Required Commands in Docker Image Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/dockerfile-builds.md A shell command to run inside your Docker container to check if essential AppPack commands like `bash`, `date`, `sleep`, `pgrep`, and `test` are present. Missing commands will be flagged, indicating a need for installation to ensure full AppPack functionality. ```bash # replace $YOUR_IMAGE with the name of your image docker run --rm -it $YOUR_IMAGE /bin/sh -c 'for c in bash date sleep pgrep test; do command -v $c || echo ✘ $c MISSING; done' ``` -------------------------------- ### Configure Node.js and Python Buildpacks in app.json Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This JSON configuration for `app.json` demonstrates how to include both the `heroku/nodejs` and `heroku/python` buildpacks. This setup is necessary when static files need to be built using Node.js before Django's `collectstatic` command runs. Ensure `package.json` and `package-lock.json` are in the repository root and a build script is defined. ```json { "buildpacks": [{"url": "heroku/nodejs"}, {"url": "heroku/python"}] } ``` -------------------------------- ### Remove Apppack Config Variable via CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/config-variables.md This command allows you to completely remove a specific config variable from your Apppack application. The example demonstrates removing `SECRET_KEY` from the `my-app` application. ```shell apppack -a my-app config unset SECRET_KEY ``` -------------------------------- ### Configure Django Cache with django-redis (Django < 4.0) Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This Python code snippet provides Django settings for configuring a Redis cache using the `django-redis` package, suitable for Django versions prior to 4.0. It connects to the AppPack Redis add-on using `REDIS_URL` and `REDIS_PREFIX` environment variables, ensuring compatibility with older Django setups. ```python import os CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": os.environ.get("REDIS_URL", "redis://127.0.0.1:6379") + "/0", "KEY_PREFIX": os.environ.get("REDIS_PREFIX", ""), "OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"}, }, } ``` -------------------------------- ### Set Apppack Config Variable via CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/config-variables.md Use this command to set a new config variable or update an existing one for your Apppack application. The example sets `SECRET_KEY` for `my-app`, encrypting the value in AWS Parameter Store and triggering an application restart to apply the change. ```shell apppack -a my-app config set SECRET_KEY=this-is-a-secret ``` -------------------------------- ### Configure Django Cache with Built-in Redis (Django 4.0+) Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This Python code snippet configures Django's built-in Redis cache backend for versions 4.0 and above. It uses `REDIS_URL` and `REDIS_PREFIX` environment variables to connect to the AppPack Redis add-on. This setup leverages Django's native Redis support, requiring only the `redis` package in requirements. ```python import os CACHES = { "default": { "BACKEND": "django.core.cache.backends.redis.RedisCache", "LOCATION": os.environ.get("REDIS_URL", "redis://127.0.0.1:6379"), "KEY_PREFIX": os.environ.get("REDIS_PREFIX", ""), } } ``` -------------------------------- ### Build AppPack Docs Locally Source: https://github.com/apppackio/apppack-docs/blob/main/README.md Instructions to set up and run the AppPack documentation site locally. This process requires Python 3.9 and PDM for dependency management and serving the documentation. ```shell pdm sync pdm run mkdocs serve ``` -------------------------------- ### Create a new AppPack application Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This command initiates the creation of a new application named 'python-demo' within AppPack. It prompts the user for various configuration details such as the cluster, repository URL, branch for continuous deployment, optional custom domain, healthcheck path, add-ons, and email addresses for app managers. ```shell apppack create app python-demo ``` -------------------------------- ### Expected output for AppPack apps list Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This snippet shows the typical output when running 'apppack auth apps', indicating the account and the listed applications, in this case, 'python-demo'. ```shell === Apps Account: (us-east-1) python-demo ``` -------------------------------- ### apppack.toml Review App Configuration Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apppack_toml.md Configures commands specific to review applications, including one-time initialization and pre-destruction hooks. ```APIDOC [review_app] initialize_command: string Values: A command, e.g. "python manage.py load_initial_data" Default: "" Required: No Description: The command used to perform a one-time initialize a review app. This is the equivalent of 'postdeploy' on Heroku. pre_destroy_command: string Values: A command, e.g. "python manage.py teardown_review_app" Default: "" Required: No Description: The command used to perform a one-time cleanup before destroying a review app. This is the equivalent of 'pr-predestroy' on Heroku. ``` -------------------------------- ### Open AppPack application in browser Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This command opens the deployed 'python-demo' application in your default web browser. It allows you to quickly verify that the application is running and accessible. ```shell apppack -a python-demo open ``` -------------------------------- ### Configure Post-Deploy Script for Review Apps in app.json Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/review-apps.md Define a `postdeploy` script in your `app.json` file to run tasks after a Review App's initial creation. This is commonly used for populating necessary initial data, ensuring the app is functional immediately. ```json { "scripts": { "postdeploy": "./bin/post_deploy.py" } } ``` -------------------------------- ### Verify access to AppPack applications Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This command lists the applications accessible to the authenticated user. It confirms successful login and verifies that the 'python-demo' application is recognized under your AWS account. ```shell apppack auth apps ``` -------------------------------- ### Trigger and monitor an AppPack application build Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This command manually triggers the CI/CD pipeline for the 'python-demo' application. The '--watch' flag monitors its progress, displaying updates as it moves through the Build, Test, Finalize, and Deploy phases. ```shell apppack -a python-demo build start --watch ``` -------------------------------- ### apppack.toml Build Configuration Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apppack_toml.md Defines how the application is built, including the build system (Dockerfile or Buildpack), specific buildpacks, builder, and Dockerfile path. ```APIDOC [build] system: string Values: dockerfile | buildpack Default: buildpack Required: No Description: The tooling used to build your app. buildpacks: array of string Values: A list of buildpacks, e.g. ["heroku/nodejs", "heroku/python"] Default: [] (use auto-detection) Required: No Description: The buildpacks used to build your app. Only used if 'system' is set to 'buildpack'. builder: string Values: A buildpack builder, e.g. "heroku/builder-cnb:22". The aliases heroku-20 (for heroku/buildpacks:20) and heroku-22 (for heroku/builder-classic:22) are also supported. Default: "heroku-20" Required: No Description: The buildpack builder used to build your app. Only used if 'system' is set to 'buildpack'. dockerfile: string Values: A path to a Dockerfile, e.g. "Dockerfile" Default: "Dockerfile" Required: No Description: The path to the Dockerfile used to build your app. Only used if 'system' is set to 'dockerfile'. ``` -------------------------------- ### apppack.toml Service Configuration Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apppack_toml.md Defines individual services for Dockerfile-based applications. Each service is a table that must contain a `command` key. ```APIDOC [services.] Type: table Values: Must have a 'command' key Default: {} Required: [services.web] is required if 'build.system' is set to 'dockerfile' Description: Each table defines a service your app will run. Only applicable if 'build.system' is set to 'dockerfile'. For buildpacks, the 'Procfile' is used instead. command: string Values: A command, e.g. "npm start" Default: "" Required: Yes Description: The command used to run the service. ``` -------------------------------- ### AppPack Deployment Pipeline with Release Task Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/releases.md This snippet illustrates the AppPack deployment pipeline, showing the sequence of steps from building and testing to finalizing, running the release task, and finally deploying the application. It highlights that the release task runs before deployment and that any failure in this task will halt the entire deployment process, preventing service updates. ```text Build → Test (optional) → Finalize → Release → Deploy ``` -------------------------------- ### Open AppPack Review App in Browser Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/review-apps.md Quickly open the deployed AppPack Review App in your default web browser. The `-a` flag specifies the target review app using its pipeline and pull request identifier. ```bash apppack -a my-app-pipeline:221 open ``` -------------------------------- ### Creating a Redis Cluster with AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/add-ons/using-redis.md This command initializes a new Redis cluster named 'my-redis' within your AppPack Cluster. It requires administrator access to execute and sets up the Redis instance for use with your applications. ```Shell apppack create redis my-redis ``` -------------------------------- ### Create AppPack Database Cluster Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/add-ons/using-databases.md This command initializes a new database cluster within your AppPack Cluster. It requires administrator access to execute successfully. ```shell apppack create database my-database ``` -------------------------------- ### Defining AppPack Release Tasks Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/releases.md This snippet demonstrates how to configure a release task in AppPack, either by adding a `release` key to your `Procfile` or by setting `deploy.release_command` in `apppack.toml`. These configurations specify a command, such as `python manage.py migrate --noinput`, to be executed once before deployment for tasks like database migrations. ```yaml release: python manage.py migrate --noinput ``` ```toml [deploy] release_command = "python manage.py migrate --noinput" ``` -------------------------------- ### Configure Django Database with dj-database-url Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Sets up the default database connection in Django settings using `dj-database-url`. It parses the `DATABASE_URL` environment variable provided by AppPack's database add-on, configuring the database with a connection max age for optimal performance. ```python import dj_database_url DATABASES = {"default": dj_database_url.config(conn_max_age=600)} ``` -------------------------------- ### Authenticate AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/tutorials/deploy-first-app.md This command authenticates the AppPack CLI with your AppPack account, allowing you to manage applications. If you signed up with an email address, ensure you verify your email via the link sent to your inbox, as this step is required for CLI authentication. ```shell apppack auth login ``` -------------------------------- ### Read Environment Variables in Django Settings Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Demonstrates how to read environment variables like `SECRET_KEY` from the operating system within Django settings. It also shows how to provide a default value for optional settings, adhering to the 12 Factor App standard for configuration. ```python import os SECRET_KEY = os.environ["SECRET_KEY"] ANOTHER_SETTING = os.environ.get("ANOTHER_SETTING", "default-value-for-another-setting") ``` -------------------------------- ### Deploy AppPack Docs via Git Push Source: https://github.com/apppackio/apppack-docs/blob/main/README.md Command to trigger the deployment of AppPack documentation to production. This action is handled by GitHub Actions when a push is made to the 'deploy/prod' branch. ```shell git push origin main:deploy/prod ``` -------------------------------- ### Create AppPack Review App from Pipeline and PR Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/review-apps.md Use this command to create a new AppPack Review App. It requires the pipeline name and the pull request number. The process involves provisioning AWS resources and triggering a build from the PR's branch. ```bash apppack reviewapps create my-app-pipeline:221 ``` -------------------------------- ### apppack.toml Test Configuration Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apppack_toml.md Specifies commands and environment variables for running tests during the build process. ```APIDOC [test] command: string Values: A command, e.g. "npm test" Default: "" Required: No Description: The command used to run your tests. env: array of string Values: A list of environment variables, e.g. ["FOO=bar", "BAZ=qux"] Default: [] Required: No Description: Environment variables to be used when building and testing your app. ``` -------------------------------- ### Copying files to S3 using AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/add-ons/working-with-files.md This command demonstrates how to copy a local file to a specific S3 bucket associated with an AppPack application. It leverages `apppack aws-exec` to provide temporary AWS credentials, enabling the use of the standard AWS CLI `s3 cp` command. ```shell apppack -a my-app aws-exec -- aws s3 cp myfile.txt s3://apppack-app-my-app-privates3bucket-1197pfxl0pxsv ``` -------------------------------- ### Define Web Service with Gunicorn in Procfile Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Configures the `web` service in the `Procfile` to run a Gunicorn server for a Django application. It binds to the port defined by the `$PORT` environment variable and allows forwarded IPs, ensuring the application listens correctly for incoming requests. ```yaml web: gunicorn --access-logfile=- --bind=0.0.0.0:$PORT --forwarded-allow-ips='*' myproject.wsgi:application ``` -------------------------------- ### GitHub Actions Workflow for AppPack Application Deployment Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/set-up/github-actions.md This YAML workflow defines a GitHub Actions job to build, test, and deploy an AppPack application. It includes steps for setting up Docker Buildx, caching, building a Docker image, running tests, configuring AWS credentials using an IAM role, and finally deploying the application using the `apppackio/deploy-action`. Users need to replace placeholders for `APPNAME`, `AWS_ROLE_ARN`, and `AWS_REGION`, and ensure an `apppack.toml` file is present. ```yaml --- name: AppPack Deploy on: [push] jobs: build: runs-on: ubuntu-latest permissions: id-token: write contents: read env: # replace this with your AppPack app name APPNAME: your-app-image BUILDX_CACHE_DIR: /tmp/.buildx-cache # replace these with the AWS role you create and the region your app is in AWS_ROLE_ARN: arn:aws:iam::123456789012:role/github-actions AWS_REGION: us-east-2 steps: - uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - uses: actions/cache@v3 with: path: ${{ env.BUILDX_CACHE_DIR }} key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx-${{ github.ref }}- ${{ runner.os }}-buildx- - name: Build Docker Image shell: bash # adds pipefail run: | docker buildx build \ --tag $APPNAME:${{ github.run_id }} \ --progress plain \ --cache-to type=local,dest=${{ env.BUILDX_CACHE_DIR }} \ --cache-from type=local,src=${{ env.BUILDX_CACHE_DIR }} \ --file Dockerfile \ --load \ . 2>&1 | tee /tmp/build.log # avoid part of build.log ending up in the image mv /tmp/build.log . - name: Test shell: bash # adds pipefail run: | # replace this with your own test command docker run --rm -e SECRET_KEY=1 $APPNAME:${{ github.run_id }} pytest | tee test.log - uses: aws-actions/configure-aws-credentials@v2 with: role-to-assume: ${{ env.AWS_ROLE_ARN }} aws-region: ${{ env.AWS_REGION }} - uses: apppackio/deploy-action@v2 with: appname: ${{ env.APPNAME }} image: ${{ env.APPNAME }}:${{ github.run_id }} ``` -------------------------------- ### Integrate Crisp Chat Analytics Script Source: https://github.com/apppackio/apppack-docs/blob/main/theme_overrides/main.html This JavaScript snippet initializes the Crisp chat widget by setting up the global Crisp array and the website ID. It then dynamically creates and appends a script tag to the document's head to load the Crisp client library asynchronously, enabling chat functionality on the page. ```JavaScript window.$crisp=[];window.CRISP_WEBSITE_ID="8969ee34-61f4-4a1a-94d9-ae3530775bd1";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})(); ``` -------------------------------- ### apppack.toml Deploy Configuration Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/apppack_toml.md Defines the command executed during the release phase of the application deployment. This is specific to Dockerfile-based systems. ```APIDOC [deploy] release_command: string Values: A command, e.g. "python manage.py migrate --noinput" Default: "" Required: No Description: The command used to release your app. Only used if 'build.system' is set to 'dockerfile'. Buildpack apps will use the 'release' key in their 'Procfile'. ``` -------------------------------- ### List Apppack Config Variables via CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/config-variables.md Execute this command to view all config variables currently configured for a specified Apppack application. It provides an overview of the environment variables available to your app. ```shell apppack -a my-app config list ``` -------------------------------- ### AppPack Database Configuration Variable Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/add-ons/using-databases.md When the database add-on is enabled for an application, the `DATABASE_URL` config variable is provided, containing the necessary credentials for connecting to the database cluster. ```APIDOC DATABASE_URL: string description: The credentials for connecting to the database cluster. ``` -------------------------------- ### Generating S3 presigned URLs with AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/add-ons/working-with-files.md This command illustrates how to generate a short-lived presigned URL for a file located in a private S3 bucket. It uses `apppack aws-exec` to authenticate the AWS CLI `s3 presign` command, allowing temporary direct access to the file via the generated URL, expiring in 600 seconds (10 minutes). ```shell apppack -a my-app aws-exec -- aws s3 presign --expires-in 600 s3://apppack-app-my-app-privates3bucket-1197pfxl0pxsv/myfile.txt ``` -------------------------------- ### Set Environment Variables using AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Adds configuration variables, such as `SECRET_KEY`, to an AppPack application using the command-line interface. This method ensures sensitive settings are managed securely outside the codebase, adhering to the 12 Factor App standard. ```shell apppack -a my-app config set SECRET_KEY=your-long-random-string ``` -------------------------------- ### Define Django Database Migration Release Task in Procfile Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This YAML snippet defines a `release` task in the `Procfile` to automatically run Django database migrations (`python manage.py migrate --noinput`) during deployment. The `release` task executes after the build process and before the new application version is deployed, ensuring database schema updates are applied seamlessly. It's crucial for migrations to be backward compatible for zero-downtime deployments. ```yaml release: python manage.py migrate --noinput ``` -------------------------------- ### Open Shell in AppPack Review App Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/review-apps.md Access a shell session directly within a running AppPack Review App. This command uses the `-a` flag to specify the application by its pipeline and pull request identifier. ```bash apppack -a my-app-pipeline:221 shell ``` -------------------------------- ### Define Background Worker Service in AppPack Procfile Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This YAML snippet demonstrates how to add a background worker process to your AppPack `Procfile`. This allows AppPack to manage and run your background task manager (e.g., Django Q's `qcluster`) as a dedicated service. ```yaml worker: python manage.py qcluster # replace with command to start the worker ``` -------------------------------- ### Configure Django Settings Module via AppPack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Sets the `DJANGO_SETTINGS_MODULE` environment variable using the AppPack command-line interface. This is crucial when the desired settings file is not the default for `manage.py` and `wsgi.py`, allowing the application to load the correct configuration. ```shell apppack -a myapp config set DJANGO_SETTINGS_MODULE=myapp.settings # replace with dotted path to your settings module ``` -------------------------------- ### Define AppPack Buildpack for Django Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md Explicitly defines the buildpack for a Python application using `app.json`. This ensures the application is correctly identified as a Python app, especially if automatic detection based on `requirements.txt` or `Pipfile` is not preferred. ```json { "buildpacks": [{"url": "heroku/python"}] } ``` -------------------------------- ### Destroy AppPack Review App Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/review-apps.md Delete an AppPack Review App and its associated resources, including databases and S3 objects. Specify the pipeline and pull request number to identify the app for deletion. ```bash apppack reviewapps destroy : ``` -------------------------------- ### Destroying an App with Apppack CLI Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/destroy-app.md This command permanently deletes a specified application and all its associated resources, including any data stored in configured add-ons. It is crucial to back up all necessary data before executing this command, as the action is irreversible. This operation can only be performed by users with administrative privileges. ```bash apppack destroy app my-app ``` -------------------------------- ### Configure Django File Storage with S3 Add-on Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This Python code snippet configures Django to use S3 for file storage via the `django-s3-storage` package. It checks for the `PRIVATE_S3_BUCKET_NAME` environment variable to enable S3 storage, setting the default file storage backend, bucket name, and key prefix. This ensures files are stored persistently in S3 rather than the ephemeral local filesystem. ```python import os # Replace 'PRIVATE' with 'PUBLIC' for the public S3 add-on if "PRIVATE_S3_BUCKET_NAME" in os.environ: DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage" AWS_S3_BUCKET_NAME = os.environ["PRIVATE_S3_BUCKET_NAME"] AWS_S3_KEY_PREFIX = os.environ.get("PRIVATE_S3_BUCKET_PREFIX", "") # AWS_S3_BUCKET_AUTH = False # Default to public files when using a public bucket ``` -------------------------------- ### Configure Django SES for Outbound Email on AppPack Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This snippet shows the necessary Django settings to integrate `django-ses` with AppPack's SES add-on. It defines the email backend, default sender, server email, and AWS SES region details, enabling email sending through AWS SES. ```python EMAIL_BACKEND = "django_ses.SESBackend" DEFAULT_FROM_EMAIL = "noreply@example.com" # Replace with a domain you've enabled in SES SERVER_EMAIL = DEFAULT_FROM_EMAIL AWS_SES_AUTO_THROTTLE = 0 AWS_SES_REGION_NAME = "us-west-2" # Replace with the region your app is deployed to AWS_SES_REGION_ENDPOINT = f"email.{AWS_SES_REGION_NAME}.amazonaws.com" ``` -------------------------------- ### Configure Celery Broker for SQS Add-on on AppPack Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/apps/deploy-django-app.md This Python snippet illustrates how to configure Celery to use the SQS Add-on as its message broker. It dynamically extracts the queue name from the `QUEUE_URL` environment variable and sets the `CELERY_BROKER_URL` accordingly for SQS integration. ```python import os QUEUE_URL = os.environ.get("QUEUE_URL", "") if QUEUE_URL.startswith("sqs://"): CELERY_TASK_DEFAULT_QUEUE = QUEUE_URL.split("/")[-1] CELERY_BROKER_URL = "sqs://" ``` -------------------------------- ### AWS IAM Role Trust Policy for GitHub Actions OIDC Source: https://github.com/apppackio/apppack-docs/blob/main/src/how-to/set-up/github-actions.md This JSON policy defines the trust relationship for an AWS IAM role, allowing GitHub Actions to assume the role using OpenID Connect (OIDC). It restricts access to a specific GitHub repository, ensuring only authorized workflows from that repository can assume the role. ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "sts:AssumeRoleWithWebIdentity", "Principal": { "Federated": "arn:aws:iam::135549385118:oidc-provider/token.actions.githubusercontent.com" }, "Condition": { "StringEquals": { "token.actions.githubusercontent.com:aud": [ "sts.amazonaws.com" ] }, "StringLike": { "token.actions.githubusercontent.com:sub": "repo:myorg/my-app-repo:*" } } } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.