Skip to content

Automated Dev Prod Deployments

Richard Salas edited this page Oct 22, 2025 · 1 revision

Automated Deployment Steps

This page outlines the procedure for deploying code automatically using environment-specific deployment scripts. These scripts replace the manual deployment process (temp process) and ensure consistent, reliable, and faster deployments to all UnlockEd environments.


Table of Contents


Purpose

  • Automate Deployments: Streamline the end-to-end deployment process for all environments.
  • Ensure Consistency: Enforce a standardized deployment pattern across Demo and Production systems.
  • Increase Speed: Deploy code in minutes rather than hours.

Overview

Each environment (Demo, Alaska, Maine, St. Louis, MoCode) has its own script that handles:

  1. Git Operations – Cloning, branch checkout, merge, and push
  2. Docker Build & Push – Building backend, frontend, and middleware images to AWS ECR
  3. Kubernetes Deployment – Restarting deployments and monitoring rollout
  4. Port Forwarding – Automatically establishing cluster access for production environments

Deployment Scripts Location

All deployment scripts are located in the UnlockedLabs shell_scripts repository:

📁 GitHub Repository:
https://github.com/UnlockedLabs/shell_scripts/tree/main/deploment_scripts

Each script corresponds to a specific environment:

Script Name Environment Branch Tag Type
deploy-demo.sh Demo (Development) demov2 demo Development
deploy-alaska.sh Alaska alaska alaska Production
deploy-maine.sh Maine maine maine Production
deploy-stlouis.sh St. Louis stlouis stlouis Production
deploy-mocode.sh MoCode mocode mocode Production

Supported Environments

Environment Branch Namespace Context
Demo (Development) demov2 demo stgdmo
Alaska alaska default alaska
Maine maine default maine
St. Louis stlouis default stlouis
MoCode mocode default mocode

How It Works

Each script executes the same general pipeline:

1. Git Operations

  • Clone the repository
  • Check out the environment-specific branch
  • Fetch latest changes and hard reset to origin/main
  • Force push updates to the environment branch

2. Docker Image Build & Push

Build and push three container images to AWS ECR using docker buildx:

  • Backendunlockedv2:<tag>
  • Frontendfrontend:<tag>
  • Provider Middlewareprovider_middleware:<tag>

3. Kubernetes Rollout

  • Switch to the correct kubectl context
  • Restart server, frontend, and provider-service deployments
  • Wait for rollout completion (up to 10,000 seconds)

4. Port Forwarding (Production Only)

  • Sets up automated port forwarding via ~/.local/bin/<env>_port_forward.sh
  • Logs available at <env>_port_forward.log

Quick Start

Deploy to Demo

./deploy-demo.sh

Deploy to a Production Environment

./deploy-alaska.sh
./deploy-maine.sh
./deploy-stlouis.sh
./deploy-mocode.sh

Command Line Options

Option Description
--workdir <path> Custom working directory (default: /tmp)
--skip-git Skip Git operations
--skip-build Skip Docker build & push
--skip-deploy Skip Kubernetes rollout
--dry-run Show planned actions without executing
-h, --help Display help message

Example:

./deploy-alaska.sh --skip-build --dry-run

Validation

After a successful deployment:

  1. Check Kubernetes Status:

    kubectl get pods
    kubectl get deployments
  2. Verify Application Health:

    • Test production endpoints
    • Confirm new image tags are running
  3. Monitor Logs:

    kubectl logs -f deployment/server
    kubectl logs -f deployment/frontend
    kubectl logs -f deployment/provider-service

Troubleshooting

Common Issues

Issue Resolution
Missing AWS Credentials Run aws configure
Missing Docker Buildx Run docker buildx install
Kubernetes Context Missing Run kubectl config get-contexts and verify
Port Forwarding Conflicts Kill process with `lsof -t -i :6443

Clean Up Temporary Files

rm -rf /tmp/*-deploy-*

Clone this wiki locally