Skip to content

Commit be9bcd4

Browse files
authored
Add entrypoint file to execute after tini. (#47)
1 parent 8f5a9b1 commit be9bcd4

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ RUN bundle check || bundle install --jobs 20 --retry 5
8181

8282
COPY . .
8383

84+
RUN chmod +x ./entrypoint.sh
85+
8486
RUN chown -R ${USER}:${USER} ${APP_PATH}
8587

86-
ENTRYPOINT ["/sbin/tini", "--"]
88+
ENTRYPOINT ["/sbin/tini", "--", "./entrypoint.sh"]
8789

8890
# Why should this go into `base` instead of `prod` stage?
8991
# CMD ["rails", "server", "-b", "0.0.0.0", "-e", "production"]

dev.entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ echo "Environment: $RAILS_ENV"
77
# install missing gems
88
bundle check || bundle install --jobs 20 --retry 5
99

10-
# Remove pre-existing puma/passenger server.pid
11-
rm -f $APP_PATH/tmp/pids/server.pid
10+
# remove pre-existing puma/passenger server.pid
11+
rm -f ${APP_PATH}/tmp/pids/server.pid
1212

1313
# run passed commands
1414
bundle exec ${@}

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# remove a potentially pre-existing server.pid for Rails.
6+
rm -f ${APP_PATH}/tmp/pids/server.pid
7+
8+
# Then exec the container's main process (what's set as CMD in the Dockerfile).
9+
exec "$@"

test.entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
echo "Environment: $RAILS_ENV"
6+
7+
# Check if we need to install new gems
8+
bundle check || bundle install --jobs 20 --retry 5
9+
10+
# Then run any passed command
11+
bundle exec ${@}

0 commit comments

Comments
 (0)