Skip to content

Commit a4cc897

Browse files
committed
Trying to improve docker workflow
1 parent 6ea6421 commit a4cc897

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM ruby:2.5
22

33
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
44
RUN apt-get update -qq && apt-get install -y build-essential \
5-
libpq-dev nodejs qt5-default libqt5webkit5-dev \
6-
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
5+
libpq-dev nodejs qt5-default libqt5webkit5-dev \
6+
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
77

88
RUN mkdir /WebsiteOne
99
WORKDIR /WebsiteOne
@@ -14,7 +14,7 @@ RUN bundle install
1414

1515
COPY package.json /WebsiteOne/package.json
1616
COPY package-lock.json /WebsiteOne/package-lock.json
17-
RUN npm install bower && npm install
17+
RUN npm install
1818

1919
COPY . /WebsiteOne
2020

docker-compose.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ services:
33
db:
44
image: postgres
55
volumes:
6-
- ./tmp/db:/var/lib/postgresql/data:rw
6+
- dbVolume:/var/lib/postgresql/data
77
web:
88
build: .
99
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
1010
volumes:
11-
- .:/WebsiteOne
11+
- webVolume:/WebsiteOne
1212
ports:
1313
- "3000:3000"
1414
depends_on:
1515
- db
16+
17+
volumes:
18+
dbVolume:
19+
webVolume:

docker/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# How to use docker to spin up WebSiteOne
2+
3+
## Setup docker
4+
5+
Execute this setup just for the first time, or when you want to recreate everything from scratch.
6+
7+
**BE AWARE IT WILL DELETE ALL YOUR DATA, including the Postgres Database.**
8+
9+
```
10+
$ ./docker/setup.sh
11+
```
12+
13+
## Start docker
14+
15+
Start the application
16+
17+
```
18+
$ ./docker/start.sh
19+
```
20+
21+
## Stop docker
22+
23+
Stop the application
24+
25+
```
26+
$ ./docker/stop.sh
27+
```
28+
29+
ps: those docker commands were tested under the following environment:
30+
31+
- MacOS 10.13.6
32+
- Docker version 18.06.0-ce, build 0ffa825
33+
- docker-compose version 1.22.0, build f46880f
34+
35+
If it doesn't work for you, try to check your docker version and consider upgrading it if you have an older version.

docker/setup.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
docker-compose down --rmi all --volumes --remove-orphans
4+
docker-compose build --force-rm --no-cache
5+
docker-compose run --rm web rake db:create
6+
docker-compose run --rm web rake db:migrate RAILS_ENV=development
7+
docker-compose run --rm web rake db:seed

docker/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
docker-compose down
4+
docker-compose up

docker/stop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker-compose down

0 commit comments

Comments
 (0)