Skip to content

Commit e53616a

Browse files
committed
Move the bundle and node_moduels to volumes for easier installs, automate install & db migrations via the entrypoints
1 parent f003e6c commit e53616a

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

bin/docker-debug-entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/bin/bash
2+
set -euo pipefail # Use strict-mode in based to ensure errors are surfaced early
23

3-
rails db:prepare
4-
rdbg -n -o -c -- bin/rails s -p 3009 -b '0.0.0.0'
4+
# Check if bundle install needs to be run
5+
bundle check >/dev/null 2>&1 || bundle install --jobs "${BUNDLE_JOBS:-4}"
6+
7+
# Check if yarn install needs to be run
8+
if [ -f package.json ] && command -v yarn >/dev/null 2>&1; then
9+
yarn install --check-files --frozen-lockfile || yarn install --check-files
10+
fi
11+
12+
# Prepare the database
13+
bundle exec rails db:prepare
14+
15+
exec rdbg -n -o -c -- bundle exec rails s -p 3009 -b '0.0.0.0'

bin/docker-entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/bin/bash
2+
set -euo pipefail # Use strict-mode in based to ensure errors are surfaced early
23

3-
rails db:prepare
4-
rails server --port 3009 --binding 0.0.0.0
4+
# Check if bundle install needs to be run
5+
bundle check >/dev/null 2>&1 || bundle install --jobs "${BUNDLE_JOBS:-4}"
6+
7+
# Check if yarn install needs to be run
8+
if [ -f package.json ] && command -v yarn >/dev/null 2>&1; then
9+
yarn install --check-files --frozen-lockfile || yarn install --check-files
10+
fi
11+
12+
# Prepare the database
13+
bundle exec rails db:prepare
14+
15+
exec bundle exec rails server --port 3009 --binding 0.0.0.0

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ services:
2626
condition: service_healthy
2727
volumes:
2828
- .:/app
29+
- bundle-data:/usr/local/bundle
30+
- node-modules:/app/node_modules
2931
# This is here to avoid rails finding stale pid-files in tmp/pids and then
3032
# thinking it is already running:
3133
- type: tmpfs
@@ -53,3 +55,5 @@ services:
5355

5456
volumes:
5557
postgres-data:
58+
bundle-data:
59+
node-modules:

0 commit comments

Comments
 (0)