Skip to content

Commit 08b27df

Browse files
committed
Dockerize application
1 parent e42b0ae commit 08b27df

File tree

6 files changed

+59
-30
lines changed

6 files changed

+59
-30
lines changed

.env.development.sample

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Define ENV variables for development environment
2-
DATABASE_URL="postgresql://localhost/ruby_jobs_development"
3-
SERVE_STATIC_ASSETS="true"
4-
WEB_SESSIONS_SECRET="238d8ece1579f59647fe3d7c5ca2c78f02142a6392506a929d14c46424e52543"
5-
MODERATION_SESSIONS_SECRET="f62e64af694897dd5a3b949891f2715ada568401017905098809aa80e8943dd0"
6-
REDISTOGO_URL="redis://localhost:6379"
2+
HANAMI_ENV=development
3+
DATABASE_URL=postgres://safelylaunch@postgres/core
4+
SERVE_STATIC_ASSETS=true
5+
WEB_SESSIONS_SECRET=238d8ece1579f59647fe3d7c5ca2c78f02142a6392506a929d14c46424e52543
6+
MODERATION_SESSIONS_SECRET=f62e64af694897dd5a3b949891f2715ada568401017905098809aa80e8943dd0
7+
REDISTOGO_URL=redis://redis:6379
78

8-
MODERATION_LOGIN="login"
9-
MODERATION_PASSWORD="password"
9+
MODERATION_LOGIN=login
10+
MODERATION_PASSWORD=password
1011

11-
ROLLBAR_KEY = 'test'
12+
ROLLBAR_KEY=test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/public/assets*
22
/tmp
33
/coverage
4+
5+
.env.development

Dockerfile.development

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ruby:2.5.0-alpine
2+
3+
RUN apk add --no-cache build-base postgresql postgresql-dev libpq git
4+
5+
WORKDIR /app
6+
COPY . /app
7+
RUN bundle install -j $(nproc) --quiet
8+
9+
ENTRYPOINT ["bundle", "exec"]

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: help dockerize shell
2+
3+
help:
4+
@echo 'Available targets:'
5+
@echo ' make dockerize'
6+
@echo ' make shell'
7+
8+
dockerize:
9+
docker-compose -f docker-compose.development.yml up --build
10+
11+
shell:
12+
docker-compose -f docker-compose.development.yml exec web sh

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,27 @@
33

44
Welcome to your new Hanami project!
55

6-
## Setup
6+
## How to run app inside Docker
77

8-
How to run tests:
8+
Copy development env-file from sample file:
99

10-
```
11-
% bundle exec rake
10+
```bash
11+
cp .env.development.sample .env.development
1212
```
1313

14-
How to run the development console:
14+
Then simply run in your terminal:
1515

16+
```bash
17+
make dockerize
1618
```
17-
% bundle exec hanami console
18-
```
19-
20-
How to run the development server:
2119

22-
```
23-
% bundle exec hanami server
24-
```
20+
Open [http://localhost:2300](http://localhost:2300) in your browser.
2521

26-
How to prepare (create and migrate) DB for `development` and `test` environments:
22+
## How to get container's shell
2723

28-
```
29-
% bundle exec hanami db prepare
24+
Run in your terminal:
3025

31-
% HANAMI_ENV=test bundle exec hanami db prepare
26+
```bash
27+
make shell
3228
```
3329

34-
Explore Hanami [guides](http://hanamirb.org/guides/), [API docs](http://docs.hanamirb.org/1.3.0.beta1/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸

docker-compose.development.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
version: '3'
2+
23
services:
4+
redis:
5+
image: redis:latest
6+
37
postgres:
48
image: postgres:9.6.2-alpine
59
environment:
610
POSTGRES_USER: safelylaunch
711
POSTGRES_DB: core
12+
ports:
13+
- 5432:5432
14+
815
web:
9-
build: .
16+
build:
17+
context: .
18+
dockerfile: Dockerfile.development
19+
command: sh -c "hanami db migrate && hanami server --host=0.0.0.0"
1020
volumes:
1121
- .:/app
1222
ports:
13-
- "2300:2300"
23+
- 2300:2300
1424
depends_on:
1525
- postgres
16-
environment:
17-
DATABASE_URL: postgres://safelylaunch@postgres/core
18-
HANAMI_ENV: development
26+
- redis
27+
env_file:
28+
- .env.development

0 commit comments

Comments
 (0)