From ef54ef485ad466e7ce1cab1328a935bb3839729f Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Sun, 8 Apr 2018 03:56:18 -0400 Subject: [PATCH 1/3] Track Dockerfiles accross instances. --- containers/docker-compose-production.yml | 32 ++++++++++++++++++++++++ containers/docker-compose-stable.yml | 30 ++++++++++++++++++++++ containers/docker-compose-unstable.yml | 30 ++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 containers/docker-compose-production.yml create mode 100644 containers/docker-compose-stable.yml create mode 100644 containers/docker-compose-unstable.yml diff --git a/containers/docker-compose-production.yml b/containers/docker-compose-production.yml new file mode 100644 index 00000000000..f971cc2e332 --- /dev/null +++ b/containers/docker-compose-production.yml @@ -0,0 +1,32 @@ +version: "2" +services: + db: + ports: + - "127.0.0.1:3307:3306" + image: mariadb:10.2 + restart: unless-stopped + environment: + - MYSQL_DATABASE=plots_$RAILS_ENV + - MYSQL_USER=plots + - MYSQL_PASSWORD=plots + - MYSQL_RANDOM_ROOT_PASSWORD=true + volumes: + - ./config/my.cnf:/etc/mysql/my.cnf + # for configuration + - ../mysql:/var/lib/mysql + # for persistence + - ../dump:/docker-entrypoint-initdb.d + # for importing a dump + # if you want to re-import simply put away ../mysql/* +# web: +# build: . +# command: /bin/bash -c "sleep 5 && bundle exec rails s -p 4000 -b '0.0.0.0'" +# environment: +# - RAILS_ENV=${RAILS_ENV} +# volumes: +# - .:/app +# ports: +# - "127.0.0.1:4001:4000" +# links: +# - db +# restart: unless-stopped diff --git a/containers/docker-compose-stable.yml b/containers/docker-compose-stable.yml new file mode 100644 index 00000000000..4e5f478ffdc --- /dev/null +++ b/containers/docker-compose-stable.yml @@ -0,0 +1,30 @@ +version: "2" +services: + db: + image: mariadb:10.2 + environment: + - MYSQL_DATABASE=plots + - MYSQL_USER=plots + - MYSQL_PASSWORD=plots + - MYSQL_RANDOM_ROOT_PASSWORD=true + volumes: + - ../mysql:/var/lib/mysql + # for persistence + - ../dump:/docker-entrypoint-initdb.d + # for importing a dump + # if you want to re-import simply put away ../mysql/* + web: + build: . + command: /bin/bash -c "sleep 5 && passenger start -p 4000" + environment: + - RAILS_ENV=${RAILS_ENV} + - SOLR_URL=${SOLR_URL} + - SECRET_KEY_BASE=${SECRET_KEY_BASE} + - DISABLE_SOLR_CHECK=1 + volumes: + - .:/app + ports: + - "127.0.0.1:4000:4000" + links: + - db +# restart: unless-stopped diff --git a/containers/docker-compose-unstable.yml b/containers/docker-compose-unstable.yml new file mode 100644 index 00000000000..d0844736bc4 --- /dev/null +++ b/containers/docker-compose-unstable.yml @@ -0,0 +1,30 @@ +version: "2" +services: + db: + image: mariadb:10.2 + environment: + - MYSQL_DATABASE=plots + - MYSQL_USER=plots + - MYSQL_PASSWORD=plots + - MYSQL_RANDOM_ROOT_PASSWORD=true + volumes: + - ./config/my.cnf:/etc/mysql/my.cnf + # for configuration + - ../mysql:/var/lib/mysql + # for persistence + - ../dump:/docker-entrypoint-initdb.d + # for importing a dump + # if you want to re-import simply put away ../mysql/* + web: + build: . + command: /bin/bash -c "sleep 5 && passenger start -p 5001" + environment: + - RAILS_ENV=${RAILS_ENV} + - SECRET_KEY_BASE=${SECRET_KEY_BASE} + volumes: + - .:/app + ports: + - "127.0.0.1:5001:5001" + links: + - db +# restart: unless-stopped From 8c9713795214b9fab1f02ed6318f98ec4b1f9b02 Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Sat, 19 May 2018 03:02:05 -0500 Subject: [PATCH 2/3] Added make targets for deployment and cron service start --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Makefile b/Makefile index 69028cd1584..e30039cc4d2 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,21 @@ +build: + cp config/database.yml.example config/database.yml + cp db/schema.rb.example db/schema.rb + docker-compose down --remove-orphans + docker-compose build + +deploy-container: + docker-compose run web sleep 5 + docker-compose run web rake db:migrate + docker-compose run web bower install --allow-root + docker-compose run web bower update --allow-root + docker-compose run web rake assets:precompile + test -e tmp/pids/server.pid && rm tmp/pids/server.pid + docker-compose up -d + docker-compose exec -T web bash -c "echo 172.19.0.1 smtp >> /etc/hosts" + docker-compose exec -T web bundle exec whenever --update-crontab + docker-compose exec -T web service start cron + install-dev: echo "Installing RubyGems" bundle install --without production mysql From 08739cfd4f5bf2e27b61e2655d8be925d9de1baa Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Thu, 24 May 2018 13:09:30 -0500 Subject: [PATCH 3/3] Specify jessie as base --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3fc5b20b6db..d4409c1b766 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Dockerfile # Plots2 # https://github.com/publiclab/plots2 -FROM ruby:2.3 +FROM ruby:2.3-jessie LABEL maintainer="Sebastian Silva " LABEL description="This image deploys Plots2."