Skip to content

Commit

Permalink
Add some instructions for first-time visitors
Browse files Browse the repository at this point in the history
  • Loading branch information
ElMassimo committed Mar 8, 2021
1 parent a63bb87 commit 99cd3c6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \

CMD ["/bin/bash"]

FROM builder as development
FROM builder AS development

ADD . /app
WORKDIR /app
COPY . .

RUN bundle install
RUN npm install

CMD ./docker-entrypoint.sh
CMD ["bin/rails", "console"]
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,32 @@
An example on how to configure Docker to run a [Vite.js](http://vitejs.dev/) process alongside a Rails app.

The integration is powered by [Vite Rails](https://github.com/ElMassimo/vite_rails).

## Setup 💿

To prepare the Docker image, run:

```bash
docker-compose build
```

To start the Rails and Vite services, run:

```bash
docker-compose up
```

## Debugging 🐞

You can verify that the Vite dev server can be reached from Rails by running:

```bash
docker-compose run --rm --entrypoint "bin/rails c" rails
```

and then:

```ruby
> ViteRuby.instance.dev_server_running?
=> true
```
16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
version: "3.9"
services:
rails:
build: .
ports:
- "3000:3000"
build:
dockerfile: Dockerfile
context: .
target: development
depends_on:
- vite
entrypoint: ./docker-rails.sh
environment:
RAILS_ENV: development
VITE_RUBY_HOST: vite
ports:
- "3000:3000"
volumes:
- .:/app
depends_on:
- vite
vite:
build:
dockerfile: Dockerfile
context: .
target: development
entrypoint: ./docker-vite.sh
environment:
DEBUG: '*vite*'
RAILS_ENV: development
VITE_RUBY_HOST: 0.0.0.0
command: ./bin/vite dev
ports:
- "3036:3036"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh → docker-rails.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# docker-entrypoint.sh
#!/bin/sh

rm -f tmp/pids/server.pid
bin/rails server -b 0.0.0.0
4 changes: 4 additions & 0 deletions docker-vite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

npm install
bin/vite dev

0 comments on commit 99cd3c6

Please sign in to comment.