Replies: 3 comments 1 reply
-
If you need to restart the container for changes to take effect, it's likely that you are not mounting the source code dirs correctly, so the image needs to be rebuilt in order for changes to be picked up. I'd recommend reading this Dockerizing Rails guide. It should be simple to adapt the webpacker steps for Vite Rails, and it will ensure that volumes are mounted in a way that changes don't require restarting your server. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the documentation, however, it didn't help. Totally desperate, I ended up just copying the docker-compose.yml of this exemple linked in the documentation, the only difference is I use the Vue plugin in addition, and still, it does not work, no HMR, no change on page refresh, only the build when the container starts. version: '3.9'
services:
db:
# ...
app:
build: .
container_name: udb_app
command: bin/rails server -b 0.0.0.0
volumes:
- .:/myapp
depends_on:
- db
ports:
- 3000:3000
environment:
DEBUG: '*vite*'
RAILS_ENV: development
VITE_RUBY_HOST: vite
vite:
build: .
container_name: udb_vite
entrypoint: ./docker-vite.sh
environment:
DEBUG: '*vite*'
RAILS_ENV: development
VITE_RUBY_HOST: 0.0.0.0
ports:
- 3036:3036
volumes:
- .:/myapp import { defineConfig } from 'vite'
import RubyPlugin from 'vite-plugin-ruby'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
RubyPlugin(),
vue()
]
}) Everything is working fine if I just run |
Beta Was this translation helpful? Give feedback.
-
Just realized the title was partly wrong and missleading, I fixed it. I never had to rebuild the image to have my changes to take effect, just to restart the container. Also, my volume seem to be fine as changes to ruby code take effect on page reload. The To me it looks like there's something wrong with the path of the files that should be whatched, but why does the very first request to the app actually builds eveything correctly ? As I wrote this sentence, I wondered if it could be due to the whole thing running in production environment, but it isn't, the files are compiled/resolved only when the first request hits, not when the container starts. I'll try to get more people into this conversation as you suggested, as I can't figure out what's wrong so far. |
Beta Was this translation helpful? Give feedback.
-
I've been trying to run a Rails 7/Inertia.js/Vue app for days, both Rails and Vite are started by Foreman. The whole thing runs in a single Docker container. The code is properly compiled when I start the container but if I want my changes to take effect I need to restart the container, refreshing the page doesn't work (since the front is in a Vue component).
docker-compose.yml
.foreman
Procfile.dev
vite.json
The terminal when I run
docker-compose up
Chrome console
Chrome WS networking
Has anyone ever managed to run Rails 7 and Vite through Foreman ?
Beta Was this translation helpful? Give feedback.
All reactions