Skip to content

Commit

Permalink
Remove config/master.key from Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster committed Apr 26, 2024
1 parent 16adaae commit 0cc9328
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ EXPOSE 3000

RUN chmod 755 /rails/bin/docker-entrypoint

# Remove master key so that the Docker image does not have it
RUN rm -f config/master.key

ENV RAILS_ENV=production

# Entrypoint prepares the database.
Expand Down
5 changes: 5 additions & 0 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if [[ -z "${LD_PRELOAD+x}" ]] && [[ -f /usr/lib/*/libjemalloc.so.2 ]]; then
export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)"
fi

# Create config/master.key from the env variable
if [[ -n ${RAILS_MASTER_KEY} && ! -s config/master.key ]]; then
echo -n ${RAILS_MASTER_KEY} > config/master.key
fi

# If running the rails server then create or migrate existing database
if [[ "${1}" == "./bin/rails" ]] && [[ "${2}" == "server" ]]; then
./bin/rails db:prepare
Expand Down

0 comments on commit 0cc9328

Please sign in to comment.