From 1cb26c9133afe1b1c36db833dc5146ba492f8663 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 3 Feb 2016 15:07:48 -0500 Subject: [PATCH] Run docker commands right from ansible task instead of through a shell script --- roles/rails/tasks/web.yml | 6 ++++-- roles/rails/tasks/worker.yml | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/roles/rails/tasks/web.yml b/roles/rails/tasks/web.yml index fffe8ca..21a65b9 100644 --- a/roles/rails/tasks/web.yml +++ b/roles/rails/tasks/web.yml @@ -4,6 +4,8 @@ - name: Copy the code from repository git: repo={{ repository }} dest=/root/wrestlingApp -- name: Create and start apache docker image - command: chdir=/root/wrestlingApp bash rails-prod.sh wrestlingdev-web +- name: Create apache docker image + command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile . +- name: Start docker container + command: docker run -h $HOSTNAME -d --restart=always --env-file /root/prod.env -v /srv/docker/apache2/logs:/var/log/apache2 -v /etc/localtime:/etc/localtime -p 80:80 -p 443:443 wrestlingdev-web diff --git a/roles/rails/tasks/worker.yml b/roles/rails/tasks/worker.yml index ff539f9..d48fff3 100644 --- a/roles/rails/tasks/worker.yml +++ b/roles/rails/tasks/worker.yml @@ -4,5 +4,8 @@ - name: Copy the code from repository git: repo={{ repository }} dest=/root/wrestlingApp -- name: Create and run delayed job worker - command: chdir=/root/wrestlingApp bash rails-prod.sh wrestlingdev-worker +- name: Create apache docker image + command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile . + +- name: Start docker container + command: docker run -h $HOSTNAME -d --restart=always --env-file /root/prod.env -v /etc/localtime:/etc/localtime wrestlingdev-worker bundle exec rake jobs:work RAILS_ENV=production