Skip to content

Commit

Permalink
Fixed build chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kleinhenz committed Mar 24, 2016
1 parent c1ffc30 commit f16d2bf
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/ansible/storyquest-playbook.retry
/editor/template/bower_components
/editor/ssl.crt
/editor/sub.class1.server.ca.pem
Expand Down
60 changes: 60 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Building and Deploying StoryQuest

The following text describes the build and deployment process for
StoryQuest maintainers. This process might not be interesting for
other people.

## Step 1: Local Build

For the following steps, you will need nave.sh, grunt and bower installed. If you don't use
nave.sh, replace those steps accordingly:

nave.sh use stable
npm install bower-cli -g
npm install grunt

StoryQuest should run with the current node stable release. We recommend strongly to use
nave.sh for development environment setup.

To build the project, change to the source directory and issue the build command:

grunt build

This builds the static web tree and creates the output dist directory containing
the web frontend and the node service and all dependencies.

## Step 2: Upload Build Artifact to GitHub

Give the `tar.gz` release file in `builds` a new version name and upload it as
a release to GitHub, creating a git tag.

## Step 3: Building and Uploading a Docker Release Build

To build a Docker image and upload it to the Docker registry, first edit
the Dockerfile and set the new version name (that you selected above):

RUN curl -L -o /tmp/storyquest.tgz <new github release url>

Then build the image locally, tagging it with the version string
(the same as above):

docker build -t kleinhenz/storyquest:<new version name> .

Then upload it into the docker registry:

docker push kleinhenz/storyquest:<new version name>

Note that the Docker build *will not use the local build*, but download
the release `tar.gz` from GitHub.

## Step 4: Updating the Production Server with Ansible

To deploy StoryQuest, issue the following command in the `ansible` directory:

ansible-playbook storyquest-playbook.yml -i ansible_hosts -s --private-key <PATH_TO>/<YOUR_KEY_>.pem

This will install the system on the given hosts. CAUTION: installing
requires to download several GB ob data from the Docker registry and
takes a while. DO NOT INTERRUPT THE ANSIBLE PROCESS. This might
cause the Docker daemon on the target machine to go bonkers.

11 changes: 8 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ module.exports = function (grunt) {
dot: true,
src: [
'.tmp',
'<%= appConfig.dist %>/{,*/}*',
'!<%= appConfig.dist %>/.git{,*/}*'
'./dist',
'./builds',
'./node_modules',
'./editor/node_modules',
'./editor/template/bower_components',
'./editor/frontend/bower_components'
]
}]
},
Expand Down Expand Up @@ -349,7 +353,7 @@ module.exports = function (grunt) {
cwd: './frontend/js',
dest: '<%= appConfig.dist %>/js/',
src: ['snippets/markdown.js']
}, {
},{
expand: true,
cwd: '.tmp/images',
dest: '<%= appConfig.dist %>/images',
Expand Down Expand Up @@ -398,6 +402,7 @@ module.exports = function (grunt) {
'mailtemplates/*',
'service/**/*',
'template/**/*',
'node_modules/**/*',
'storyquest.js',
'package.json'
],
Expand Down
24 changes: 12 additions & 12 deletions ansible/storyquest-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
remote_user: ubuntu
sudo: true
tasks:
- name: Make sure apt-transport-https is installed
- name: make sure apt-transport-https is installed
apt:
pkg: "apt-transport-https"
state: installed

- name: Add Docker repository key
- name: add Docker repository key
apt_key:
id: "36A1D7869245C8950F966E92D8576A8BA88D21E9"
keyserver: "hkp://keyserver.ubuntu.com:80"
state: present

- name: Add Docker repository and update apt cache
- name: add Docker repository and update apt cache
apt_repository:
repo: "deb http://get.docker.io/ubuntu docker main"
update_cache: yes
Expand All @@ -23,7 +23,7 @@
- name: update server
apt: update_cache=yes

- name: upgrad server
- name: upgrade server
apt: upgrade=full

- name: upload project backup script
Expand All @@ -34,7 +34,7 @@
become: yes
become_user: ubuntu

- name: Install dependencies
- name: install dependencies
apt:
pkg: "{{ item }}"
state: installed
Expand All @@ -43,19 +43,19 @@
- python-dev
- python-pip

- name: Make sure pip is upgraded
- name: make sure pip is upgraded
command: easy_install -U pip

- name: Make sure Docker-py is installed
- name: make sure Docker-py is installed
pip:
name: docker-py

- name: Make sure docker is running
- name: make sure docker is running
service:
name: docker
state: started

- name: Start couchdb-docker
- name: start couchdb-docker
docker:
docker_api_version: 1.18
image: klaemo/couchdb
Expand All @@ -68,10 +68,10 @@
- "/data/couchdb/couchdb-data:/usr/local/var/lib/couchdb"
- "/data/couchdb/couchdb-logs:/usr/local/var/log/couchdb"

- name: Start storyquest-docker
- name: start storyquest-docker
docker:
docker_api_version: 1.18
image: kleinhenz/storyquest-builds
image: kleinhenz/storyquest:v3.0.0-alpha
name: storyquest
restart_policy: always
pull: always
Expand All @@ -94,5 +94,5 @@
env:
CONFIGFILE: /opt/app/config.json

- name: Remove all untagged docker images
- name: remove all untagged docker images
shell: docker rmi $(docker images -q -f dangling=true)

0 comments on commit f16d2bf

Please sign in to comment.