Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- name: Set environment up
run: |
docker-compose pull
docker-compose build
docker-compose run --rm web bundle install
docker-compose run --rm web bundle exec rake db:setup
docker-compose run --rm web bundle exec rake db:test:prepare

- name: Run specs
run: |
docker-compose run --rm web bundle exec rspec

build:
needs: test
runs-on: ubuntu-22.04
env:
DOCKER_REPOSITORY: 'instedd/mbuilder'
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
steps:
- uses: actions/checkout@v2
- name: Build image & push to Docker Hub
run: ./build.sh
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ruby:2.0

# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

# # Install dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
nodejs \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /app

# Install gem bundle
ADD Gemfile /app/
ADD Gemfile.lock /app/
RUN bundle install --jobs 3 --without development test

# Install the application
ADD . /app

# Precompile assets
RUN bundle exec rake assets:precompile RAILS_ENV=production SECRET_KEY_BASE=secret

ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_ENV=production
EXPOSE 80

# Add scripts
ADD docker/database.yml /app/config/database.yml

CMD ["puma", "-e", "production", "-b", "tcp://0.0.0.0:80"]
13 changes: 13 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ruby:2.0

# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

# # Install dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
nodejs \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /app
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'rails', '~> 3.2.17'
gem 'mysql2'

Expand Down Expand Up @@ -57,7 +59,7 @@ group :development, :test do
gem 'fakefs', :require => 'fakefs/safe'
gem 'machinist'
gem 'capistrano', '2.15.4'
gem 'rvm-capistrano'
gem 'rvm-capistrano', require: false
gem 'timecop'
gem 'rails-dev-tweaks'
end
76 changes: 38 additions & 38 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
GIT
remote: git://github.com/instedd/alto_guisso.git
remote: https://bitbucket.org/instedd/pigeon.git
revision: 50f5268e3690071937cdcce581a29922ef723bf7
branch: master
specs:
instedd-pigeon (0.3.1)
json
rails (~> 3.2)
rest-client
twilio-ruby
twitter_oauth

GIT
remote: https://bitbucket.org/instedd/resource_map_api_client.git
revision: c08251ba1888e6469c24328b55e279f11c22e152
branch: master
specs:
resource_map_api_client (0.0.1)
alto_guisso
memoist

GIT
remote: https://github.com/instedd/alto_guisso
revision: 6d72573c211f45ff95d36847af733449acdfa04a
branch: master
specs:
alto_guisso (0.0.2)
rack-oauth2

GIT
remote: git://github.com/instedd/alto_guisso_rails.git
remote: https://github.com/instedd/alto_guisso_rails
revision: bd944d08c59e5835285f0d956fb1fb00402fc385
branch: master
specs:
Expand All @@ -20,7 +41,7 @@ GIT
ruby-openid

GIT
remote: git://github.com/instedd/instedd-bootstrap.git
remote: https://github.com/instedd/instedd-bootstrap
revision: f7677c0a25064c5feb9e199be739253ec8973b3a
branch: master
specs:
Expand All @@ -30,15 +51,27 @@ GIT
sass-rails

GIT
remote: git://github.com/instedd/ruby-hub_client.git
remote: https://github.com/instedd/recurring_select
revision: a20ad65f609239cd9d37dd8904dc9a43726cef31
branch: instedd
specs:
recurring_select (1.2.1)
coffee-rails (>= 3.1)
ice_cube (>= 0.11)
jquery-rails (>= 3.0)
rails (>= 3.2)
sass-rails (>= 3.1)

GIT
remote: https://github.com/instedd/ruby-hub_client
revision: 9fef94a685e4ba16a9826e00cc22fd88c3a0cef9
branch: master
specs:
hub_client (0.0.1)
rest-client

GIT
remote: git://github.com/instedd/telemetry_rails.git
remote: https://github.com/instedd/telemetry_rails
revision: cc25f9b8bf6cbafa92f9012c72a9da7e5675d392
branch: master
specs:
Expand All @@ -47,39 +80,6 @@ GIT
global_phone_dbgen
rails

GIT
remote: https://bitbucket.org/instedd/pigeon.git
revision: 50f5268e3690071937cdcce581a29922ef723bf7
branch: master
specs:
instedd-pigeon (0.3.1)
json
rails (~> 3.2)
rest-client
twilio-ruby
twitter_oauth

GIT
remote: https://bitbucket.org/instedd/resource_map_api_client.git
revision: c08251ba1888e6469c24328b55e279f11c22e152
branch: master
specs:
resource_map_api_client (0.0.1)
alto_guisso
memoist

GIT
remote: https://github.com/instedd/recurring_select
revision: a20ad65f609239cd9d37dd8904dc9a43726cef31
branch: instedd
specs:
recurring_select (1.2.1)
coffee-rails (>= 3.1)
ice_cube (>= 0.11)
jquery-rails (>= 3.0)
rails (>= 3.2)
sass-rails (>= 3.1)

GEM
remote: https://rubygems.org/
specs:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ mBuilder is a Ruby on Rails application. It uses/depends on:
* **guisso** (optional) in order to integrate with InSTEDD's Single Sign-On. [more](http://login.instedd.org)
* **resourcemap** (optional) in order to read/write data to resourcemap collections. [more](http://resourcemap.instedd.org)

## Setup
## Docker Development

You can set up a `docker-compose`-based development environment by running the `./dev-setup.sh` script on the repo's root. Then `docker-compose up` to start all the services.

## Local Setup

1. Checkout
2. Setup rails project as usual. `$ bundle && rails db:create db:schema:load`
Expand Down
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -eo pipefail

# This will load the script from this repository. Make sure to point to a specific commit so the build continues to work
# event if breaking changes are introduced in this repository
source <(curl -s https://raw.githubusercontent.com/manastech/ci-docker-builder/14726d1aa865b754686818b51a9cbefe75da7943/build.sh)

# Prepare the build
dockerSetup

# Write a VERSION file for the footer
echo $VERSION > VERSION

# Build and push the Docker image
dockerBuildAndPush
2 changes: 2 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
development:
adapter: mysql2
host: <%= ENV["DATABASE_HOST"] %>
encoding: utf8
database: mbuilder_development
pool: 5
Expand All @@ -8,6 +9,7 @@ development:

test:
adapter: mysql2
host: <%= ENV["DATABASE_HOST"] %>
encoding: utf8
database: mbuilder_test
pool: 5
Expand Down
6 changes: 6 additions & 0 deletions dev-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
docker-compose pull
docker-compose build
docker-compose up -d db
docker-compose run --rm --no-deps web bundle install
docker-compose run --rm web bash -c 'rake db:setup db:seed'
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '2.0'

services:
db:
image: mysql:5.5
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- db:/var/lib/mysql

elasticsearch:
image: elasticsearch:1.7.5
volumes:
- elasticsearch:/usr/share/elasticsearch/data

web: &rails
build:
context: .
dockerfile: Dockerfile.dev
environment:
DATABASE_HOST: 'db'
ELASTICSEARCH_URL: 'http://elasticsearch:9200'
volumes:
- .:/app
- bundle:/usr/local/bundle
tmpfs: /app/tmp
depends_on:
- db
- elasticsearch
command: rails server -b 0.0.0.0 -p 80
ports:
- 80

delayed:
<<: *rails
command: "bundle exec rake jobs:work"
ports: []

volumes:
db:
bundle:
elasticsearch:
2 changes: 2 additions & 0 deletions docker/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
production:
url: <%= ENV['DATABASE_URL'] %>