Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Enable continuous deployment with CircleCI
Browse files Browse the repository at this point in the history
* Make ./bin/release-version dev deploy with Docker
* Enable release-version in circle.yml
Fixes #2521
  • Loading branch information
ianb committed May 9, 2017
1 parent 4a35e31 commit 0d0f42c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ zip: addon
bootstrap_zip: addon
@rm -f build/screenshots-bootstrap.zip
cd addon && zip -rq ../build/screenshots-bootstrap.zip .
# build/screenshots-bootstrap.js created
# build/screenshots-bootstrap.zip created

.PHONY: signed_xpi
signed_xpi: addon
Expand Down Expand Up @@ -261,7 +261,9 @@ help:
@echo " make clean"
@echo " rm -rf build/ addon/webextension/build"
@echo " make zip"
@echo " make a zip of the webextension in build/screenshots.zip"
@echo " make an unsigned zip of the webextension in build/screenshots.zip"
@echo " make bootstrap_zip"
@echo " make an unsigned zip of addon/ in build/screenshots.zip"
@echo " make signed_xpi"
@echo " make a signed xpi in build/screenshots.xpi"
@echo "See also:"
Expand Down
18 changes: 11 additions & 7 deletions bin/build-docker-image
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ export NODE_ENV=production
cd "$(dirname ${BASH_SOURCE[0]})/.."

if [[ $# = 0 ]] ; then
echo "Usage: $0 dockerhubusername"
echo "Usage: $0 dockerhubusername [version]"
echo " builds the Screenshots docker image"
echo " Determines version from package.json"
echo " tags and uploads it as [dockerhubusername]/pageshot:[version]"
echo " tags and uploads it as [dockerhubusername]/screenshots:[version]"
echo " creates build/eb-app-latest.zip"
echo " version defaults to latest"
echo " version is read from package.json if not provided"
exit 4
fi

version="$(node -e 'console.log(require("./package.json").version)')"
if [[ -n "$2" ]] ; then
version="$2"
else
version="$(node -e 'console.log(require("./package.json").version)')"
fi

sed "s!USERNAME!$1!g" < Dockerrun.aws.json.template > Dockerrun.aws.json.tmp
sed "s!VERSION!$version!g" < Dockerrun.aws.json.tmp > Dockerrun.aws.json
Expand All @@ -29,6 +33,6 @@ if [[ ! -e "$xpi" ]] ; then
make signed_xpi
fi

echo "Creating docker image $1/pageshot:$version"
docker build -t $1/pageshot:"$version" .
docker push $1/pageshot:"$version"
echo "Creating docker image $1/screenshots:$version"
docker build -t $1/screenshots:"$version" .
docker push $1/screenshots:"$version"
17 changes: 8 additions & 9 deletions bin/release-version
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@ fi

case "$channel" in
dev)
if [[ -z "$DOCKER_USERNAME" ]] ; then
echo "Please set \$DOCKER_USERNAME to your dockerhub username"
exit 3
if [[ "$(current_branch)" != "master" ]] ; then
echo "Note: deploying from branch $(current_branch) (master expected)"
fi
rm -f build/screenshots.zip
rm -f build/screenshots.xpi
# Forces update of the add-on version:
mkdir -p build
touch build/.backend.txt
SCREENSHOTS_BACKEND=https://pageshot.dev.mozaws.net SCREENSHOTS_SENTRY="$dev_sentry" make signed_xpi
./bin/build-docker-image $DOCKER_USERNAME
SCREENSHOTS_BACKEND=https://screenshots.dev.mozaws.net SCREENSHOTS_SENTRY="$dev_sentry" make signed_xpi
./bin/build-docker-image mozilla latest
echo
echo "Next step: upload build/eb-app-latest.zip to http://amzn.to/1NuC3N9"
echo "Dev deployment automatically triggered, see #screenshots IRC for status"
;;
stage)
if [[ "$(current_branch)" != "stable" ]] && [[ -z "$IGNORE_BRANCH" ]] ; then
Expand All @@ -55,7 +54,7 @@ case "$channel" in
echo " IGNORE_BRANCH=1 $(basename $0) stage"
exit 4
fi
rm -f build/screenshots.zip
rm -f build/screenshots.xpi
# Forces update of the add-on version:
touch build/.backend.txt
SCREENSHOTS_BACKEND=https://screenshots.stage.mozaws.net SCREENSHOTS_SENTRY="$stage_sentry" make signed_xpi
Expand All @@ -80,4 +79,4 @@ case "$channel" in
exit 2
esac

which growlnotify > /dev/null && growlnotify -m "Screenshots Deploy/container for ${channel} completed"
which growlnotify > /dev/null && growlnotify -m "Screenshots Deploy/container for ${channel} completed" || true
9 changes: 9 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
machine:
services:
- docker
node:
version: 6.10.0
environment:
Expand Down Expand Up @@ -34,3 +36,10 @@ test:

post:
- bash <(curl -s https://codecov.io/bash)

deployment:
dev:
branch: master
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
- ./bin/release-version dev
4 changes: 3 additions & 1 deletion docs/docker.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
**Note:** Most of what is described in these instructions is implemented in the `./bin/release-version` script.

To create the docker image, first run:

make server
make xpi
make signed_xpi

Then, manually sign the xpi (in the build directory) using the AMO website, download the signed copy, replace the unsigned copy, and use:

Expand Down

0 comments on commit 0d0f42c

Please sign in to comment.