Skip to content

Commit

Permalink
chore: add sandbox deployment scripts (#3817)
Browse files Browse the repository at this point in the history
* chore: add sandbox deployment scripts

* fix: tweak cli

* fix: use versioned image
  • Loading branch information
rpcross authored Aug 15, 2024
1 parent 8491ce2 commit f476e0a
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ on:
- Skip
- Staging Only
- Staging + Prod
sandbox:
description: 'Deploy to Sandbox'
default: false
required: true
type: boolean
sandboxNoDbRefresh:
description: 'Sandbox Disable Daily DB Refresh'
default: false
required: true
type: boolean

jobs:
publish:
Expand Down Expand Up @@ -241,3 +251,43 @@ jobs:
wait-for-completion: true
wait-for-completion-timeout: 10m
display-workflow-run-url: false

# -----------------------------------------------------------------
# SANDBOX
# -----------------------------------------------------------------
sandbox:
name: Deploy to Sandbox
if: ${{ !failure() && !cancelled() && github.event.inputs.sandbox == 'true' }}
needs: [prepare, release]
runs-on: [self-hosted, dev-server]
environment:
name: sandbox
env:
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}

steps:
- uses: actions/checkout@v4

- name: Download a Release Artifact
uses: actions/[email protected]
with:
name: release-${{ env.PKG_VERSION }}

- name: Deploy to containers
env:
DEBIAN_FRONTEND: noninteractive
run: |
# echo "Reset production flags in settings.py..."
# sed -i -r -e 's/^DEBUG *= *.*$/DEBUG = True/' -e "s/^SERVER_MODE *= *.*\$/SERVER_MODE = 'development'/" backend/mlarchive/settings/base.py
echo "Install Deploy to Container CLI dependencies..."
cd dev/deploy-to-container
npm ci
cd ../..
echo "Start Deploy..."
node ./dev/deploy-to-container/cli.js --branch ${{ github.ref_name }} --domain dev.ietf.org --appversion ${{ env.PKG_VERSION }} --commit ${{ github.sha }} --ghrunid ${{ github.run_id }} --nodbrefresh ${{ github.event.inputs.sandboxNoDbRefresh }}
- name: Cleanup old docker resources
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker image prune -a -f
1 change: 1 addition & 0 deletions dev/deploy-to-container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
3 changes: 3 additions & 0 deletions dev/deploy-to-container/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
audit = false
fund = false
save-exact = true
22 changes: 22 additions & 0 deletions dev/deploy-to-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Mail Archive Deploy to Container Tool

This tool takes a release.tar.gz build file and deploys it as a container, along with its own database container.

## Requirements

- Node `16.x` or later
- Docker

## Usage

1. From the `dev/deploy-to-container` directory, run the command:
```sh
npm install
```
2. Make sure you have a `release.tar.gz` tarball in the project root directory.
3. From the project root directory (back up 2 levels), run the command: (replacing the `branch` and `domain` arguments)
```sh
node ./dev/deploy-to-container/cli.js --branch main --domain something.com
```

A container named `ma-app-BRANCH` and `ma-db-BRANCH` (where BRANCH is the argument provided above) will be created.
Loading

0 comments on commit f476e0a

Please sign in to comment.