Improve docker automation

This commit is contained in:
riggraz
2019-08-26 10:41:46 +02:00
parent c67774334c
commit 5cf71687c8
6 changed files with 22 additions and 9 deletions

View File

@@ -12,7 +12,6 @@ COPY Gemfile.lock /app/Gemfile.lock
RUN bundle install RUN bundle install
RUN yarn install --check-files RUN yarn install --check-files
RUN yarn install
COPY . /app COPY . /app

View File

@@ -6,6 +6,8 @@ services:
- ./tmp/db:/var/lib/postgresql/data - ./tmp/db:/var/lib/postgresql/data
web: web:
build: . build: .
environment:
- UPDATE=0
volumes: volumes:
- .:/app - .:/app
ports: ports:

View File

@@ -3,15 +3,24 @@
# Exit immediately if a command exits with a non-zero status. # Exit immediately if a command exits with a non-zero status.
set -e set -e
# Create database, load schema, run migrations and seed data in an idempotent way. if [ "$UPDATE" = 1 ]; then
echo "Preparing database..." echo "UPDATE (yarn packages, db preparation and webpack compilation)"
rake db:prepare
echo "Database prepared."
# Use webpack to build JS and CSS. # Launch yarn install
echo "Compiling JS and CSS with webpack..." echo "Launching yarn install..."
./bin/webpack yarn install
echo "Webpack compilation completed." echo "yarn install successfully executed."
# Create database, load schema, run migrations and seed data in an idempotent way.
echo "Preparing database..."
rake db:prepare
echo "Database prepared."
# Use webpack to build JS and CSS.
echo "Compiling JS and CSS with webpack..."
./bin/webpack
echo "Webpack compilation completed."
fi
# Remove a potentially pre-existing server.pid for Rails. # Remove a potentially pre-existing server.pid for Rails.
rm -f /app/tmp/pids/server.pid rm -f /app/tmp/pids/server.pid

1
script/docker-build.sh Executable file
View File

@@ -0,0 +1 @@
docker-compose build

1
script/docker-run.sh Executable file
View File

@@ -0,0 +1 @@
docker-compose up "$@"

1
script/docker-update.sh Executable file
View File

@@ -0,0 +1 @@
docker-compose run --rm -e UPDATE=1 web echo "Update completed."