mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add db preparation and webpack compilation when launching the container
This commit is contained in:
@@ -9,16 +9,15 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY Gemfile /app/Gemfile
|
COPY Gemfile /app/Gemfile
|
||||||
COPY Gemfile.lock /app/Gemfile.lock
|
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
|
||||||
|
|
||||||
# Add a script to be executed every time the container starts.
|
# Add a script to be executed every time the container starts.
|
||||||
COPY entrypoint.sh /usr/bin/
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||||
RUN chmod +x /usr/bin/entrypoint.sh
|
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ services:
|
|||||||
- ./tmp/db:/var/lib/postgresql/data
|
- ./tmp/db:/var/lib/postgresql/data
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
20
docker-entrypoint.sh
Executable file
20
docker-entrypoint.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit immediately if a command exits with a non-zero status.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 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."
|
||||||
|
|
||||||
|
# Remove a potentially pre-existing server.pid for Rails.
|
||||||
|
rm -f /app/tmp/pids/server.pid
|
||||||
|
|
||||||
|
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
||||||
|
exec "$@"
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Remove a potentially pre-existing server.pid for Rails.
|
|
||||||
rm -f /app/tmp/pids/server.pid
|
|
||||||
|
|
||||||
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
|
||||||
exec "$@"
|
|
||||||
Reference in New Issue
Block a user