Skip to content
Permalink
Browse files

Docker dev setup (#2849)

* Add docker binstubs

* Add a way to run the dev app with docker

* Readd decidim requirements to the docs

* Notes about docker setup for development

* Remove unnecessary quoting

* Bring gems mount point up to date

* Fix mention to base image in circleCI

* Bump test image to latest
  • Loading branch information...
deivid-rodriguez authored and josepjaume committed Mar 15, 2018
1 parent 419e3ba commit 15ca59d3e32a3944cb9a6fead08a13162802492f
Showing with 65 additions and 9 deletions.
  1. +2 −2 .circleci/config.yml
  2. +3 −0 d/bash
  3. +3 −0 d/bundle
  4. +3 −0 d/gem
  5. +3 −0 d/rails
  6. +5 −0 d/rake
  7. +8 −0 d/rspec
  8. +3 −3 docker-compose.yml
  9. +35 −4 docs/getting_started.md
@@ -3,8 +3,8 @@ version: 2
defaults: &defaults
docker:
# This is the sha of the latest `decidim/decidim:latest-test` docker image. You can retrieve the
# latest digest by doing `$ docker pull decidim/decidim:latest-dev`.
- image: decidim/decidim@sha256:348fb1faa49cfe76ba7cbeafc67ca09002cf95f0ffa7a76eefa9d5b3774e0ee9
# latest digest by doing `$ docker pull decidim/decidim:latest-test`.
- image: decidim/decidim@sha256:e2dc624d6a7ca2ee02080d1dcec0ed255a71b7bc4101afb2d2508dbf9568c77e
environment:
BUNDLE_GEMFILE: /app/Gemfile
SIMPLECOV: true
3 d/bash
@@ -0,0 +1,3 @@
#!/bin/bash

docker-compose run --rm decidim bash "$@"
@@ -0,0 +1,3 @@
#!/bin/bash

docker-compose run --rm decidim bundle "$@"
3 d/gem
@@ -0,0 +1,3 @@
#!/bin/bash

docker-compose run --rm decidim gem "$@"
@@ -0,0 +1,3 @@
#!/bin/bash

docker-compose run --service-ports --rm decidim bash -c "cd development_app && bin/rails $*"
5 d/rake
@@ -0,0 +1,5 @@
#!/bin/bash

fail_fast=${FAIL_FAST:-false}

docker-compose run --rm -e "FAIL_FAST=$fail_fast" decidim bash -c "bundle exec rake $*"
@@ -0,0 +1,8 @@
#!/bin/bash

gem=${1%%/*}
spec=${1#*/}
fail_fast=${FAIL_FAST:-false}
folder=${gem:-.}

docker-compose run --rm -e "FAIL_FAST=$fail_fast" decidim bash -c "cd $folder && bundle exec rspec $spec"
@@ -4,12 +4,12 @@ services:
image: decidim/decidim:latest-dev
entrypoint: /usr/local/bin/entrypoint.sh
command: decidim
working_dir: "/code"
working_dir: /code
ports:
- "3000:3000"
- 3000:3000
volumes:
- .:/code
- gems:/gems:delegated
- gems:/usr/local/bundle:delegated
environment:
- DATABASE_HOST=pg
- DATABASE_USERNAME=postgres
@@ -25,18 +25,46 @@ Read more about the [installation script](https://github.com/alabs/decidim-insta

### B. Using Docker [experimental]

> *Please note that this is **experimental***
You can also use [docker v17+] && [docker-compose] to develop decidim. You'll
need to install those but in exchange you don't need to install any other
dependency in your computer, not even Ruby!

To get started, first clone the decidim repo

```console
git clone https://github.com/decidim/decidim
```

Switch to the cloned folder

Make sure you [have Docker v17 at least](https://docs.docker.com/engine/installation/). `cd` to your preferred folder and run this command:
```console
cd decidim
```

Then create a development application

```console
docker run --rm -v $(pwd):/tmp codegram/decidim bash -c "bundle exec decidim /tmp/decidim_application"
d/bundle install
d/rake development_app
cd development_app
bin/rails server
```

This will create a `decidim_application` Ruby on Rails app using Decidim in the current folder. It will install the latest released version of the gem.
In general, to use the docker development environment, change any instruction in
the docs to use its equivalent docker binstub. So for example, instead of
running `bundle install`, you would run `d/bundle install`.

### C. Step by step

In order to develop on decidim, you'll need:

* **Git** 2.15+
* **PostgreSQL** 9.4+
* **Ruby** 2.5.0 (2.3+ should work just fine, but that's the version we test against)
* **NodeJS** 9.x.x
* **ImageMagick**
* **Chrome** browser and [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/).

First of all, you need to install the `decidim` gem:

```console
@@ -139,3 +167,6 @@ bin/rails decidim:check_locales

Be aware that this task might not be able to detect everything, so make sure you
also manually check your application before upgrading.

[docker]: https://docs.docker.com/engine/installation/
[docker-compose]: https://docs.docker.com/compose/install/

0 comments on commit 15ca59d

Please sign in to comment.
You can’t perform that action at this time.