-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐳 docker image and deploy script #84
base: master
Are you sure you want to change the base?
Changes from 9 commits
6b5a33a
fb90a57
8f5d786
256e7f5
4616085
c6dd075
6d9f950
e75758b
9b39eaf
2ea64c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 🪂 Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
release: | ||
types: [published, edited, prereleased] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: 🔨 Build and deploy docker image | ||
uses: WGBH-MLA/.github/.github/workflows/build.yml@main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.capistrano | ||
stuff | ||
.DS_Store | ||
.DS_Store | ||
*.pem |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM ruby:3.1 | ||
WORKDIR /root | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
|
||
RUN bundle install | ||
|
||
CMD bundle exec cap aws deploy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
HELP="deploy script for AAPB and OpenVault3 \n\n | ||
|
||
USAGE \n | ||
./deploy COMMAND [ARGS] \n\n | ||
|
||
COMMANDS \n | ||
b | build \t\t Build the deployer image \n | ||
deploy \t\t Run the deployer with environment vars passed in \n | ||
h | help \t\t Show this message \n\n | ||
|
||
|
||
Requires a local SSH_KEY. \n | ||
All environment variables must be exported in the current session, \n | ||
or passed in on the command line." | ||
|
||
IMAGE_NAME=aapb-deploy | ||
|
||
VOLUME_MOUNT="-v `pwd`:/root/" | ||
DOCKER_ARGS="docker run -it $VOLUME_MOUNT" | ||
|
||
|
||
if [ $1 = "build" -o $1 = "b" ]; then | ||
shift | ||
# build the docker image | ||
docker build -t $IMAGE_NAME . "$@" | ||
|
||
elif [ $1 = "deploy" ]; then | ||
shift | ||
# deploy AAPB or OpenVault | ||
$DOCKER_ARGS \ | ||
-e BRANCH \ | ||
-e APP_NAME \ | ||
-e REPO_URL \ | ||
-e SSH_HOST \ | ||
-e SSH_KEY \ | ||
$IMAGE_NAME "$@" | ||
|
||
else | ||
echo "command not recognized: $@" | ||
echo -e $HELP | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
### | ||
# Command line tool for managing AAPB and OpenVault deployments | ||
### | ||
from os.path import realpath | ||
from subprocess import PIPE, STDOUT | ||
from subprocess import run as sub_run | ||
|
||
import click | ||
|
||
GITHUB_URL = 'https://github.com/WGBH-MLA/' | ||
DOCKER_IMAGE = 'ghcr.io/wgbh-mla/openvault3_deploy:pr-84' | ||
|
||
|
||
def run_interactive(cmd: str): | ||
"""Run a shell command in an interactive terminal""" | ||
return sub_run(cmd, shell=True, capture_output=True, check=True).stdout.decode() | ||
|
||
|
||
@click.command() | ||
@click.argument( | ||
"context", | ||
required=True, | ||
type=click.Choice(["aapb", "aapb-demo", "openvault", "openvault-demo"]), | ||
) | ||
@click.argument( | ||
"branch", | ||
required=True, | ||
) | ||
def deploy(context, branch): | ||
"""Deploy AAPB or OpenVault instance""" | ||
|
||
click.echo(f"Deploying: { context }") | ||
click.echo(f"Branch: { branch }") | ||
cmd = f"""docker run -it -v {realpath('')}:/root/ {DOCKER_IMAGE}""" | ||
|
||
sub_run(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrharpo how does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot about this file. This was a secondary attempt after the Not sure why I would prefer this over the env var approach. We can probably delete this file, since the regular bash version is sufficient. |
||
|
||
|
||
if __name__ == "__main__": | ||
deploy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this getting in the way? Seems like removing it opens up a new risk of incompatibility between the Capistrano version and our config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added with e75758b
Seems to be working fine with the upgraded capistrano version, so I'm fine continuing with the latest for now, until it becomes a problem, when we can lock it.