Skip to content

Commit f637cff

Browse files
committed
Docker improvements
Better docker-compose config Ruby 2.5.3 Alpine demo Deploy with ssh-agent and .ssh/config Documentation
1 parent 5577210 commit f637cff

File tree

5 files changed

+75
-31
lines changed

5 files changed

+75
-31
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.1
1+
2.5.3

Dockerfile

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,52 @@
1+
# Decidim Application Dockerfile
2+
#
3+
# This is an image to be used with docker-compose, to develop Decidim (https://decidim.org) locally.
4+
#
5+
#
6+
7+
# Starts with a clean ruby image from Debian (slim)
18
FROM ruby:2.5.3
29

10+
# Installs system dependencies
11+
ENV DEBIAN_FRONTEND noninteractive
312
RUN apt-get update -qq && apt-get install -y \
413
build-essential \
514
libpq-dev \
615
nodejs \
716
imagemagick
817

18+
# Bleeding edge, I have some doubts with Alpine and glibc
19+
##
20+
## Starts with a clean ruby image from Alpine Linux
21+
#FROM ruby:2.5.3-alpine
22+
#
23+
## Installs system dependencies
24+
#RUN apk add --update --no-cache \
25+
# build-base \
26+
# file \
27+
# imagemagick \
28+
# libc6-compat \
29+
# nodejs \
30+
# postgresql-dev \
31+
# tzdata \
32+
# xz-libs
33+
34+
# Sets workdir as /app
935
RUN mkdir /app
1036
WORKDIR /app
1137

12-
ENV BUNDLE_PATH=/bundle \
13-
BUNDLE_BIN=/bundle/bin \
14-
GEM_HOME=/bundle
38+
# Installs bundler dependencies
39+
ENV BUNDLE_PATH=/app/vendor/bundle \
40+
BUNDLE_BIN=/app/vendor/bundle/bin \
41+
BUNDLE_JOBS=5 \
42+
BUNDLE_RETRY=3 \
43+
GEM_HOME=/bundle
1544
ENV PATH="${BUNDLE_BIN}:${PATH}"
1645
ADD Gemfile /app/Gemfile
1746
ADD Gemfile.lock /app/Gemfile.lock
47+
# Specific por DDDC/decode
1848
ADD decidim-petitions/ /app/decidim-petitions
1949
RUN bundle install
2050

51+
# Copy all the code to /app
2152
ADD . /app

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ DEPENDENCIES
857857
web-console (~> 3.5)
858858

859859
RUBY VERSION
860-
ruby 2.5.1p57
860+
ruby 2.5.3p105
861861

862862
BUNDLED WITH
863863
1.17.2

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,27 @@ implementing the [DECODE](https://decodeproject.eu/) prototypes.
1010

1111
You will need to do some steps before having the app working properly once you've deployed it:
1212

13-
1. Clone this repository:
14-
```console
13+
1. Clone this repository, go to the directory and starts with docker-compose
14+
```bash
1515
git clone https://github.com/alabs/DDDC
16-
```
17-
2. Go to the directory:
18-
```console
1916
cd DDDC
17+
docker-compose up
18+
docker-compose run app rails db:create
19+
docker-compose run app rails db:migrate
20+
docker-compose run app rails db:seed
2021
```
21-
3. Install the gems:
22-
```console
23-
bundle install
24-
```
25-
4. Set up the database. If you need you can change your settings using the environment variables from config/database.yml:
26-
```console
27-
rails db:create
28-
rails db:migrate
29-
rails db:seed
30-
```
31-
5. Start the web server:
32-
```console
33-
rails server
22+
23+
Go to http://localhost:3000/
24+
25+
### Staging
26+
27+
```bash
28+
docker-compose run app bundle exec cap staging deploy
3429
```
3530

3631
### Production
3732

38-
You should deploy it as other Ruby on Rails applications, using Capistrano or other methods for deployment that you prefer.
33+
Push master branch to Heroku.
3934

4035
## About petitions module
4136

@@ -110,3 +105,4 @@ An example with curl:
110105
curl 'https://betadddc.alabs.org/api' -H 'content-type: application/json' --data '{"query":"{\n petition(id:\"1\") {\n id, \n title,\n description,\n author,\n json_schema \n }\n}\n","variables":null,"operationName":null}'
111106
```
112107

108+

docker-compose.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
1-
version: '3'
1+
version: '3.1'
22
services:
33
app:
44
build: .
55
volumes:
66
- .:/app
7-
- bundle_cache:/bundle
8-
- node_modules:/app/node_modules
7+
- app_assets:/app/public/assets/
8+
- app_bundle:/app/vendor/bundle
9+
- app_file_storage:/app/public/system/
10+
- app_logs:/app/logs/
11+
# For deploy with capistrano, pass the .ssh/config and ssh-agent
12+
- ~/.ssh:/root/.ssh
13+
- $SSH_AUTH_SOCK:/ssh-agent
914
environment:
1015
- PORT=3000
1116
- DATABASE_HOST=pg
1217
- DATABASE_USERNAME=postgres
1318
- RAILS_ENV=development
1419
- REDIS_URL=redis://redis:6379
20+
- SSH_AUTH_SOCK=/ssh-agent
21+
depends_on:
22+
- pg
23+
- redis
1524
ports:
1625
- 3000:3000
1726
links:
1827
- pg
1928
- redis
20-
command: bash -c "rm tmp/pids/server.pid ; bundle exec rails server -b 0.0.0.0"
29+
command: bundle exec puma
2130
worker:
2231
build: .
2332
volumes:
2433
- .:/app
25-
- bundle_cache:/bundle
34+
- app_assets:/app/public/assets/
35+
- app_bundle:/app/vendor/bundle
36+
- app_file_storage:/app/public/system/
37+
- app_logs:/app/logs/
2638
environment:
2739
- DATABASE_HOST=pg
2840
- DATABASE_USERNAME=postgres
2941
- RAILS_ENV=development
3042
- REDIS_URL=redis://redis:6379
43+
depends_on:
44+
- pg
45+
- redis
3146
links:
3247
- pg
3348
- redis
@@ -41,7 +56,9 @@ services:
4156
volumes:
4257
- redis-data:/data
4358
volumes:
44-
node_modules: {}
45-
bundle_cache: {}
59+
app_assets: {}
60+
app_bundle: {}
61+
app_file_storage: {}
62+
app_logs: {}
4663
pg-data: {}
4764
redis-data: {}

0 commit comments

Comments
 (0)