Skip to content

Commit 68fad69

Browse files
authored
Setup and execute in development using docker-compose (#655)
* Setup entire application using docker compose * No need to include node_modules in the app image These are installed by npm install * Reduce build context size by ignoring unneeded deps * No need to rebuild node-sass since we're not copying node_modules
1 parent 8bcd0c7 commit 68fad69

File tree

8 files changed

+141
-17
lines changed

8 files changed

+141
-17
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ Help would be appreciated! Please join us in [slack #flaredown](https://rubyforg
1515
* Redis 6.2.3
1616
* Ruby 3.0.6 (see [RVM](https://rvm.io/) also)
1717
* Node 12.22.6
18+
1819
## Installation
1920

21+
All dependencies are dockerized, including the application and can be run using `docker compose` so there's no dependencies to install other than docker.
22+
23+
If you want to run the application on your own machine see the next sections on dependency installations
24+
25+
### Mac
26+
2027
_If you are running on an M1 mac, run the following command before you start the installation process:_
2128
```bash
2229
$env /usr/bin/arch -arm64 /bin/zsh ---login
@@ -54,7 +61,22 @@ npm install
5461

5562
## Running / Development
5663

64+
### Docker
65+
5766
From the project root:
67+
68+
```bash
69+
docker compose --profile dev up
70+
```
71+
72+
This will build and run all the containers necessary to run the application locally.
73+
74+
Visit your app at [http://localhost:4300](http://localhost:4300)
75+
76+
### Local Machine Installation
77+
78+
From the project root:
79+
5880
```bash
5981
docker compose up
6082
```
@@ -63,8 +85,6 @@ docker compose up
6385
rake run
6486
```
6587

66-
Visit your app at [http://localhost:4300](http://localhost:4300)
67-
6888
## CI
6989

7090
Several checks are configured to run on all commits using Github Actions, including lint, build and test steps. Definitions can be found in [./github/workflows](./github/workflows). Those checks which always run are required to be successful for PRs to be mergable.

backend/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ruby:3.0
2+
3+
# set working directory
4+
WORKDIR /app
5+
6+
# install dependencies
7+
RUN apt-get update -qq && \
8+
apt-get install -y nodejs postgresql-client
9+
10+
# install bundler
11+
RUN gem install bundler:2.1.4
12+
13+
# copy the Gemfile and Gemfile.lock to the container
14+
COPY Gemfile Gemfile.lock ./
15+
16+
# install the gems
17+
RUN bundle install
18+
19+
# copy the rest of the application files to the container
20+
COPY . .
21+
22+
# start the server
23+
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

backend/config/database.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default: &default
22
adapter: postgresql
33
encoding: unicode
4-
host: localhost
4+
host: <%= ENV.fetch('PG_DATABASE_HOST') { 'localhost' } %>
55
database: flaredown_development
66
username: postgres
77
password: password

backend/config/mongoid.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ development:
99
# Provides the hosts the default client can connect to. Must be an array
1010
# of host:port pairs. (required)
1111
hosts:
12-
- localhost:27017
12+
- <%= ENV['MONGODB_HOST'] || "localhost" %>:27017
1313
options:
1414
# Change the default write concern. (default = { w: 1 })
1515
# write:

docker-compose.yml

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,87 @@
1-
version: '3'
2-
volumes:
3-
postgres:
4-
mongodb:
5-
redis:
1+
version: '3.8'
2+
x-backend-services-hosts:
3+
&backend-services-hosts
4+
MONGODB_HOST: mongodb
5+
REDIS_URL: redis://redis:6379
6+
PG_DATABASE_HOST: postgres
7+
68
services:
9+
backend:
10+
build: backend
11+
depends_on:
12+
- postgres
13+
- mongodb
14+
- redis
15+
ports:
16+
- 3000:3000
17+
volumes:
18+
- ./backend:/app
19+
environment: *backend-services-hosts
20+
profiles:
21+
- dev
22+
workers:
23+
build: backend
24+
command: bundle exec sidekiq -C config/sidekiq.yml
25+
depends_on:
26+
- redis
27+
- mongodb
28+
- postgres
29+
volumes:
30+
- ./backend:/app
31+
environment: *backend-services-hosts
32+
profiles:
33+
- dev
34+
tunnel:
35+
build: backend
36+
command: bundle exec bin/localtunnel
37+
depends_on:
38+
- backend
39+
volumes:
40+
- ./backend:/app
41+
profiles:
42+
- tunnel
43+
frontend:
44+
build: frontend
45+
depends_on:
46+
- backend
47+
ports:
48+
- 4300:4300
49+
volumes:
50+
- ./frontend:/app
51+
command: sh -c "cd /app && rm -rfd ./dist && ./node_modules/.bin/ember serve --port 4300 --proxy http://localhost:3000"
52+
profiles:
53+
- dev
54+
app-setup:
55+
build: backend
56+
command: bundle exec rails app:setup
57+
depends_on:
58+
- postgres
59+
environment: *backend-services-hosts
60+
profiles:
61+
- tools
762
postgres:
863
image: postgres:12.8-alpine
64+
restart: always
965
environment:
1066
POSTGRES_PASSWORD: password
1167
PGDATA: /data
1268
volumes:
1369
- postgres:/data
14-
ports:
15-
- 5432:5432
70+
expose:
71+
- 5432
1672
mongodb:
1773
image: mongo:4.4.9
1874
volumes:
1975
- mongodb:/data/db
20-
ports:
21-
- 27017:27017
76+
expose:
77+
- 27017
2278
redis:
2379
image: redis:6.2.3-alpine
2480
volumes:
2581
- redis:/data
26-
ports:
27-
- 6379:6379
82+
expose:
83+
- 6379
84+
volumes:
85+
postgres:
86+
mongodb:
87+
redis:

frontend/.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bower_components
2+
node_modules
3+
dist
4+
tmp
5+
.git
6+
README.md
7+
LICENSE
8+
.gitignore

frontend/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:12.22.6
2+
3+
# Force npm version 7
4+
RUN npm i -g npm@7
5+
6+
WORKDIR /app
7+
8+
COPY package*.json bower.json .bowerrc .npmrc ./
9+
10+
RUN npm install
11+
12+
COPY . .
13+
14+
CMD ["npm", "start"]

frontend/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You will need the following things properly installed on your computer.
2323
## Running / Development
2424

2525
* `ember serve`
26-
* Visit your app at [http://localhost:4200](http://localhost:4200).
26+
* Visit your app at [http://localhost:4300](http://localhost:4300).
2727

2828
## Running / Development via Fastboot server
2929

@@ -54,4 +54,3 @@ Specify what it takes to deploy your app.
5454
* Development Browser Extensions
5555
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
5656
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
57-

0 commit comments

Comments
 (0)