diff --git a/lib/generators/templates/Dockerfile.erb b/lib/generators/templates/Dockerfile.erb index 001102e..dd4a223 100644 --- a/lib/generators/templates/Dockerfile.erb +++ b/lib/generators/templates/Dockerfile.erb @@ -286,7 +286,11 @@ ENV <%= deploy_env.join(" \\\n ") %> <% else -%> # Entrypoint sets up the container. <% end -%> +<% if using_litefs? -%> +ENTRYPOINT ["litefs", "mount"] +<% else -%> ENTRYPOINT ["/rails/bin/docker-entrypoint"] +<% end -%> <% if procfile.size > 1 -%> # Build a Procfile for production use @@ -307,7 +311,7 @@ VOLUME /data CMD ["foreman", "start", "--procfile=<%= options.procfile %>"] <% elsif procfile.size > 1 -%> CMD ["foreman", "start", "--procfile=Procfile.prod"] -<% else -%> +<% elsif !using_litefs? -%> CMD <%= procfile.values.first.split(" ").inspect %> <% end -%> <% end -%> diff --git a/lib/generators/templates/litefs.yml.erb b/lib/generators/templates/litefs.yml.erb index b736b80..339de4d 100644 --- a/lib/generators/templates/litefs.yml.erb +++ b/lib/generators/templates/litefs.yml.erb @@ -77,6 +77,8 @@ proxy: # "static" which assigns a single node to be the primary and does # not failover. lease: + promote: true + # Required. Must be either "consul" or "static". type: "consul" @@ -114,3 +116,19 @@ lease: # can become leader. This buffer is intended to prevent # overlap in leadership due to clock skew or in-flight calls. lock-delay: "1s" + +exec: + # Only run migrations on candidate nodes. + - cmd: "./bin/rails db:prepare" + if-candidate: true + + # Then run the application server on all nodes. +<% if !options.procfile.blank? -%> + - cmd: "foreman start --procfile=<%= options.procfile %>" +<% elsif procfile.size > 1 -%> + - cmd: "foreman start --procfile=Procfile.prod" +<% elsif !using_litefs? -%> + - cmd: <%= procfile.values.first.split(" ").inspect %> +<% else -%> + - cmd: "./bin/rails server" +<% end -%> \ No newline at end of file diff --git a/test/results/litefs/Dockerfile b/test/results/litefs/Dockerfile index 3b592ca..493231e 100644 --- a/test/results/litefs/Dockerfile +++ b/test/results/litefs/Dockerfile @@ -73,9 +73,8 @@ ENV DATABASE_URL="sqlite3:///litefs/production.sqlite3" \ PORT="3001" # Entrypoint prepares the database. -ENTRYPOINT ["/rails/bin/docker-entrypoint"] +ENTRYPOINT ["litefs", "mount"] # Start the server by default, this can be overwritten at runtime EXPOSE 3000 VOLUME /data -CMD ["./bin/rails", "server"] diff --git a/test/results/litefs/config/litefs.yml b/test/results/litefs/config/litefs.yml index b736b80..8a54215 100644 --- a/test/results/litefs/config/litefs.yml +++ b/test/results/litefs/config/litefs.yml @@ -77,6 +77,8 @@ proxy: # "static" which assigns a single node to be the primary and does # not failover. lease: + promote: true + # Required. Must be either "consul" or "static". type: "consul" @@ -114,3 +116,12 @@ lease: # can become leader. This buffer is intended to prevent # overlap in leadership due to clock skew or in-flight calls. lock-delay: "1s" + +exec: + # Only run migrations on candidate nodes. + - cmd: "./bin/rails db:prepare" + if-candidate: true + + # Then run the application server on all nodes. + - cmd: "./bin/rails server" + \ No newline at end of file