From 5b576dbc16911e936e5244376eb1208590f2e8f9 Mon Sep 17 00:00:00 2001 From: Ryan W Date: Sat, 30 Sep 2023 21:23:39 -0700 Subject: [PATCH] Trying to get Render to run the migrations --- production.Dockerfile | 7 +++++++ render.yaml | 1 + 2 files changed, 8 insertions(+) diff --git a/production.Dockerfile b/production.Dockerfile index 7c8ef0a..5ada861 100644 --- a/production.Dockerfile +++ b/production.Dockerfile @@ -75,6 +75,13 @@ RUN useradd rails --create-home --shell /bin/bash && \ chown -R rails:rails db log storage tmp USER rails:rails +# Run database migrations when deploying to Render. It is not great, maybe there's a better way? +# https://community.render.com/t/release-command-for-db-migrations/247/6 +ARG RENDER +ARG DATABASE_URL +ARG SECRET_KEY_BASE +RUN if [ -z "$RENDER" ]; then echo "var is unset"; else bin/rails db:migrate; fi + # Entrypoint prepares the database. ENTRYPOINT ["/rails/bin/docker-entrypoint-production"] diff --git a/render.yaml b/render.yaml index 529afb9..acc5f07 100644 --- a/render.yaml +++ b/render.yaml @@ -13,6 +13,7 @@ services: region: oregon branch: main plan: free + # buildCommand: "./bin/render-build.sh" dockerCommand: "bundle exec puma -C config/puma.rb" numInstances: 1 healthCheckPath: /up