Skip to content

Commit 910ab1d

Browse files
authored
Merge pull request #630 from CodeNow/add-web-and-enterprise-sign-in
Add web and enterprise sign in
2 parents 528c6ed + c8929b4 commit 910ab1d

10 files changed

Lines changed: 162 additions & 20 deletions

File tree

ansible/enterprise-sign-in.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- hosts: web
3+
vars_files:
4+
- group_vars/alpha-enterprise-sign-in.yml
5+
roles:
6+
- { role: builder, tags: "build" }
7+
- { role: container_start }
8+
- { role: wait_for_container_exit }
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "enterprise-sign-in"
2+
3+
container_image: registry.runnable.com/runnable/{{ name }}
4+
container_tag: "{{ git_branch }}"
5+
repo: "git@github.com:CodeNow/{{ name }}.git"
6+
node_version: "4.8.0"
7+
npm_version: "2.15.11"
8+
9+
dockerfile_post_install_commands: [
10+
"wget -nv https://github.com/eSlider/sassc-binaries/raw/develop/dist/sassc -O /usr/bin/sass",
11+
"chmod +x /usr/bin/sass",
12+
"npm install -g gulp",
13+
"npm install"
14+
]
15+
16+
container_envs: >
17+
-e API_URL=https://{{ api_hostname }}
18+
-e ANGULAR_URL={{ angular_url }}
19+
-e NODE_ENV={{ node_env }}
20+
-e AWS_REGION={{ web_aws_bucket_region | default('us-east-1') }}
21+
-e AWS_BUCKET_NAME={{ domain }}
22+
-e AWS_ACCESS_KEY_ID={{ aws_access_key }}
23+
-e AWS_SECRET_ACCESS_KEY={{ aws_secret_key }}
24+
25+
container_run_opts: >
26+
-h {{ name }}
27+
-d
28+
{{container_envs}}
29+
30+
container_run_args: gulp gulp build:dev && gulp push

ansible/group_vars/alpha-web.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ repo: "git@github.com:CodeNow/{{ name }}.git"
66
node_version: "0.10.38"
77
npm_version: "2.1.18"
88
rollbar_web_token: "162a053bebd34e9eb6e2860543c7ae79"
9-
do_not_push: yes
109

11-
dockerfile_enviroment: [
12-
"API_SOCK_URL https://{{ api_socket_server_hostname }}",
13-
"API_URL https://{{ api_hostname }}",
14-
"MIXPANEL_PROXY_URL {{ mixpanel_proxy_url }}",
15-
"AWS_ACCESS_KEY {{ aws_access_key }}",
16-
"AWS_BUCKET app.{{ domain }}",
17-
"AWS_REGION {{ web_aws_bucket_region | default('us-east-1') }}",
18-
"AWS_SECRET_KEY {{ aws_secret_key }}",
19-
"INTERCOM_APP_ID {{ web_intercom_id }}",
20-
"MARKETING_URL {{ marketing_url }}",
21-
"NODE_ENV production",
22-
"SIFT_API_KEY {{ web_sift_public_key }}",
23-
"STRIPE_TOKEN {{ cream_stripe_publishable_key }}",
24-
"USER_CONTENT_DOMAIN {{ user_content_domain }}",
25-
]
10+
container_envs: >
11+
-e API_SOCK_URL=https://{{ api_socket_server_hostname }}
12+
-e API_URL=https://{{ api_hostname }}
13+
-e MIXPANEL_PROXY_URL={{ mixpanel_proxy_url }}
14+
-e AWS_ACCESS_KEY={{ aws_access_key }}
15+
-e AWS_BUCKET=app.{{ domain }}
16+
-e AWS_REGION={{ web_aws_bucket_region | default('us-east-1') }}
17+
-e AWS_SECRET_KEY={{ aws_secret_key }}
18+
-e INTERCOM_APP_ID={{ web_intercom_id }}
19+
-e MARKETING_URL={{ marketing_url }}
20+
-e NODE_ENV=production
21+
-e SIFT_API_KEY={{ web_sift_public_key }}
22+
-e STRIPE_TOKEN={{ cream_stripe_publishable_key }}
23+
-e USER_CONTENT_DOMAIN={{ user_content_domain }}
2624
27-
dockerfile_post_install_commands: [
28-
"npm run gruntDeploy"
29-
]
25+
container_run_opts: >
26+
-h {{ name }}
27+
-d
28+
{{container_envs}}
29+
30+
npm_start_command: run gruntDeploy
31+
32+
container_run_args: npm {{ npm_start_command }}

ansible/roles/builder/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
src: "{{ dockerfile }}"
5252
dest: "{{ build_dir }}/{{ name }}"
5353

54+
- name: copy .dockerignore file into build folder
55+
tags: deploy
56+
become: true
57+
template:
58+
src: ".dockerignore"
59+
dest: "{{ build_dir }}/{{ name }}"
60+
5461
- name: copy secrets into build dir
5562
tags: [ deploy ]
5663
become: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.git

ansible/roles/builder/templates/basic_node/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ RUN rm /root/.ssh/id_rsa
5454
RUN rm /root/.ssh/known_hosts
5555

5656
# Define default command.
57-
CMD ulimit -c unlimited && /usr/local/bin/npm {{ npm_start_command | default('start') }}
57+
CMD ulimit -c unlimited && /usr/local/bin/npm {{ npm_start_command | default('start') }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
IMAGE_NAME="$1"
4+
CONTAINERS=`docker ps | grep -v '^CONTAINER' | awk '{print $1}'`
5+
6+
if [ "" = "${CONTAINERS}" ] ; then
7+
exit 0
8+
else
9+
for container in ${CONTAINERS} ; do
10+
docker inspect "${container}" | grep -q '"Image": "'"${IMAGE_NAME}":
11+
if [ ${?} -eq 0 ] ; then
12+
if [ -z "${RUNNING_CONTAINERS}" ] ; then
13+
RUNNING_CONTAINERS="${container}"
14+
else
15+
RUNNING_CONTAINERS="${RUNNING_CONTAINERS} ${container}"
16+
fi
17+
fi
18+
done
19+
fi
20+
21+
if [ ! -z "${RUNNING_CONTAINERS}" ] ; then
22+
echo "${RUNNING_CONTAINERS}"
23+
fi
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
- name: get containers
3+
tags: deploy
4+
become: yes
5+
script: findTagRunning.sh {{ container_image }}
6+
register: container_ids
7+
8+
- name: wait for container to stop
9+
become: yes
10+
script: findTagRunning.sh {{ container_image }}
11+
register: result
12+
tags: deploy
13+
until: result.stdout_lines|length == 0
14+
retries: 100
15+
delay: 1
16+
17+
- name: get container exit code
18+
tags: deploy
19+
become: true
20+
command: docker inspect -f {% raw %}{{.State.ExitCode}}{% endraw %} {{ container_ids.stdout_lines[0] }}
21+
register: container_exit_code
22+
23+
- name: get logs
24+
tags: deploy
25+
shell: source /home/ubuntu/.bash_aliases && loglast {{ name }} "n 200"
26+
args:
27+
executable: /bin/bash
28+
when: container_exit_code.stdout != "0"
29+
register: last_200_lines_of_logs
30+
31+
- name: display logs for debugging purposes
32+
tags: deploy
33+
when: container_exit_code.stdout != "0"
34+
debug:
35+
var: last_200_lines_of_logs
36+
37+
- name: assert container exited with no errors
38+
tags: deploy
39+
when: container_exit_code.stdout != "0"
40+
fail:
41+
msg: "Container did not exit with code 0 (Code: {{ container_exit_code.stdout }})"

ansible/single-host-base.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,33 @@
159159
- { role: builder }
160160
- { role: squash_image }
161161

162+
- hosts: "{{ host }}"
163+
vars:
164+
- git_branch: "{{ angular_branch }}"
165+
vars_files:
166+
- "group_vars/alpha-web.yml"
167+
roles:
168+
- { role: builder }
169+
- { role: squash_image }
170+
171+
- hosts: "{{ host }}"
172+
vars:
173+
- git_branch: "{{ astral_branch }}"
174+
vars_files:
175+
- "group_vars/alpha-shiva.yml"
176+
roles:
177+
- { role: builder }
178+
- { role: squash_image }
179+
180+
- hosts: "{{ host }}"
181+
vars:
182+
- git_branch: "{{ enterprise_sign_in_branch }}"
183+
vars_files:
184+
- "group_vars/alpha-enterprise-sign-in.yml"
185+
roles:
186+
- { role: builder }
187+
- { role: squash_image }
188+
162189
# End building of images
163190

164191
- hosts: "{{ host }}"

ansible/web.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
rollbar_token: "{{ rollbar_web_token }}"
1010
tags: [ notify ]
1111
- { role: builder, tags: "build" }
12+
- { role: container_start }
13+
- { role: wait_for_container_exit }

0 commit comments

Comments
 (0)