Improve docker scripts

This commit is contained in:
riccardo
2019-09-22 15:52:53 +02:00
parent 31828d48ba
commit 3ce611374b
6 changed files with 22 additions and 11 deletions

View File

@@ -14,10 +14,12 @@ WORKDIR /app
# Launch processes in Procfile # Launch processes in Procfile
RUN gem install foreman RUN gem install foreman
COPY Gemfile /app/Gemfile # Copy Gemfile and install gems
COPY Gemfile.lock /app/Gemfile.lock COPY Gemfile* /app/
RUN bundle install RUN bundle install
# Copy package.json and install packages
COPY package.json yarn.lock /app/
RUN yarn install --check-files RUN yarn install --check-files
COPY . /app COPY . /app

View File

@@ -4,13 +4,6 @@
set -e set -e
if [ "$UPDATE" = 1 ]; then if [ "$UPDATE" = 1 ]; then
echo "UPDATE (yarn packages, db preparation and webpack compilation)"
# Launch yarn install
echo "Launching yarn install..."
yarn install
echo "yarn install successfully executed."
# Create database, load schema, run migrations and seed data in an idempotent way. # Create database, load schema, run migrations and seed data in an idempotent way.
echo "Preparing database..." echo "Preparing database..."
rake db:prepare rake db:prepare
@@ -20,6 +13,8 @@ if [ "$UPDATE" = 1 ]; then
echo "Compiling JS and CSS with webpack..." echo "Compiling JS and CSS with webpack..."
./bin/webpack ./bin/webpack
echo "Webpack compilation completed." echo "Webpack compilation completed."
exit 0
fi fi
# Remove a potentially pre-existing server.pid for Rails. # Remove a potentially pre-existing server.pid for Rails.

View File

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

View File

@@ -1 +1,3 @@
echo "Starting Astuto..."
docker-compose up "$@" docker-compose up "$@"

View File

@@ -0,0 +1,4 @@
#!/bin/bash
/bin/bash script/docker-update.sh
/bin/bash script/docker-run.sh

View File

@@ -1 +1,10 @@
docker-compose run --rm -e UPDATE=1 web echo "Update completed." echo "Starting update..."
echo "-> Docker image will be rebuilt if necessary"
echo "-> Database schema will be updated if necessary"
echo "-> Webpack will compile assets"
docker-compose build
docker-compose run --rm web yarn install # needed to avoid yarn integrity check fail
docker-compose run --rm -e UPDATE=1 web
echo "Update completed."