diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 20675457..8a004236 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -39,7 +39,7 @@ jobs: - name: Start run: | - docker run --rm --name=rails-on-docker --env SECRET_KEY_BASE=dummy ${{ env.TEST_TAG }} + docker run -d --rm --name=rails-on-docker --env SECRET_KEY_BASE=dummy ${{ env.TEST_TAG }} - name: Logs run: | diff --git a/Dockerfile b/Dockerfile index cfa299f0..84984dca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN gem update --system && gem install bundler WORKDIR /usr/src/app -ENTRYPOINT ["./bin/dev-docker-entrypoint"] +ENTRYPOINT ["./bin/docker-entrypoint"] EXPOSE 3000 diff --git a/bin/dev-docker-entrypoint b/bin/dev-docker-entrypoint deleted file mode 100755 index 329394d3..00000000 --- a/bin/dev-docker-entrypoint +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -# Remove a potentially pre-existing server.pid for Rails. -rm -f /usr/src/app/tmp/pids/server.pid - -echo "bundle install..." -bundle check || bundle install --jobs 4 - -# Then exec the container's main process (what's set as CMD in the Dockerfile). -exec "$@" diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint index 452771b7..329394d3 100755 --- a/bin/docker-entrypoint +++ b/bin/docker-entrypoint @@ -1,8 +1,11 @@ -#!/bin/bash -e +#!/bin/bash +set -e -# If running the rails server then create or migrate existing database -# if [ "${*}" == "./bin/rails server" ]; then -# ./bin/rails db:prepare -# fi +# Remove a potentially pre-existing server.pid for Rails. +rm -f /usr/src/app/tmp/pids/server.pid -exec "${@}" +echo "bundle install..." +bundle check || bundle install --jobs 4 + +# Then exec the container's main process (what's set as CMD in the Dockerfile). +exec "$@" diff --git a/bin/docker-entrypoint-production b/bin/docker-entrypoint-production new file mode 100755 index 00000000..452771b7 --- /dev/null +++ b/bin/docker-entrypoint-production @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# If running the rails server then create or migrate existing database +# if [ "${*}" == "./bin/rails server" ]; then +# ./bin/rails db:prepare +# fi + +exec "${@}" diff --git a/production.Dockerfile b/production.Dockerfile index 935e54c8..989723dc 100644 --- a/production.Dockerfile +++ b/production.Dockerfile @@ -76,7 +76,7 @@ RUN useradd rails --create-home --shell /bin/bash && \ USER rails:rails # Entrypoint prepares the database. -ENTRYPOINT ["/rails/bin/docker-entrypoint"] +ENTRYPOINT ["/rails/bin/docker-entrypoint-production"] # Start the server by default, this can be overwritten at runtime EXPOSE 3000