#Deploying inertia on rails app on a Hetzner VPS using Kamal 2
1 messages · Page 1 of 1 (latest)
Hello Shreyas, i have deploy some apps with kamal
I can share the dockerfile to you
For this i am using rails 8 with thurster
Hey Duepe! Thanks for this, I will try it out and get back 🙂
https://github.com/inertiajs/inertia-rails/pull/167 this PR also might help 👀
Thanks @turbid geyser I’m just a bit new to this and was wondering if the PR is merged to the main? Does that mean that there are some revisions left before being integrated into the inertia rails official documentation?
Yeah, there's one note about SSR url to be resolved (you can check the comments for more info)
Let me know if the recipe works for you!
@turbid geyser Tried making all the relevant changes based on the PR: https://github.com/inertiajs/inertia-rails/pull/167
and then kamal setup, but getting this error:
NH-LP-0104:kamal-inertia-shadcn-rails shreyas$ kamal setup
INFO [a6b2cfbf] Running /usr/bin/env mkdir -p .kamal on 78.47.103.193
INFO [3243668c] Running /usr/bin/env mkdir -p .kamal on 192.168.0.1
Enter passphrase for /Users/shreyas/.ssh/id_rsa:
INFO [a6b2cfbf] Finished in 3.937 seconds with exit status 0 (successful).
Finished all in 75.0 seconds
ERROR (Net::SSH::ConnectionTimeout): Exception while executing on host 192.168.0.1: Net::SSH::ConnectionTimeout
This is my git repo: https://github.com/shreyas-makes/kamal-inertia-shadcn-rails
This PR adds a new recipe to the Cookbook list, providing detailed steps on how to deploy an Inertia Rails application with Kamal, configured for SSR support.
Special thanks to @skryukov for taki...
Your ssh key requires password, so you probably need to configure ssh agent, something like this: https://github.com/basecamp/kamal/issues/589
@turbid geyser — When asked to enter passphrase, I did enter my ssh password. I have already configured my public and private SSH keys earlier.
I had even tried deploying it with this setup for a plain vanilla rails app here and it worked well: https://github.com/shreyas-makes/razorpay
the only issue I’m facing is with the inertia/ssr setup which is not being deployed, when I try ‘Kamal setup’ on this project (inertia on rails with Kamal) the terminal is just frozen in time
Hmm i think you should update vite host from 192.168.0.1 to your production ip
@turbid geyser Have updated the vite host to my production IP. Also updated the Dockerfile to have run npm instead of yarn as that was the installer I was using for my shadcn packages. Got it fixed, and kamal setup and kamal deploy works successfully.
So when I try kamal-inertia-shadcn-rails.jhanas.club, it gives me a 404 error not found.
These are the cloudflare settings:
A
(DNS only | auto TTL)
jhanas.club
points to 78.47.103.193.
A
(DNS only | auto TTL)
kamal-inertia-shadcn-rails.jhanas.club
points to 78.47.103.193.
A
(DNS only | auto TTL)
www.jhanas.club
points to 78.47.103.193.
AAAA
(DNS only | auto TTL)
jhanas.club
points to 2a01:4f8:1c1b:abe2::.
AAAA
(DNS only | auto TTL)
kamal-inertia-shadcn-rails.jhanas.club
points to 2a01:4f8:1c1b:abe2::.
AAAA
(DNS only | auto TTL)
www.jhanas.club
points to 2a01:4f8:1c1b:abe2::.
https://kamal-inertia-shadcn-rails.jhanas.club/
NH-LP-0104:kamal-inertia-shadcn-rails shreyas$ dig jhanas.club any
;; Truncated, retrying in TCP mode.
; <<>> DiG 9.10.6 <<>> jhanas.club any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2811
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;jhanas.club. IN ANY
;; ANSWER SECTION:
jhanas.club. 882 IN HINFO "RFC8482" ""
;; Query time: 24 msec
;; SERVER: fe80::8e83:94ff:fe02:fb79%15#53(fe80::8e83:94ff:fe02:fb79%15)
;; WHEN: Wed Dec 04 21:15:08 GMT 2024
;; MSG SIZE rcvd: 61
This is the dockerfile:
# syntax=docker/dockerfile:1
# check=error=true
ARG RUBY_VERSION=3.3.6
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
WORKDIR /rails
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
ARG NODE_VERSION=22.11.0
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
rm -rf /tmp/node-build-master
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
FROM base AS build
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev node-gyp pkg-config python-is-python3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
COPY .ruby-version Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN bundle exec bootsnap precompile app/ lib/
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
RUN rm -rf node_modules
FROM base
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp storage
USER 1000:1000
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
you probably want to define a root route: https://guides.rubyonrails.org/routing.html#using-root
Such a rookie mistake! Thanks for bearing with this
I can’t believe it worked, thanks a ton @turbid geyser 😇