-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable containerized demo #64
base: master
Are you sure you want to change the base?
Changes from 5 commits
cbafa85
8600667
cc588af
311ea01
adff743
c1c2369
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Provides the name of the project for docker | ||
COMPOSE_PROJECT_NAME=ror_ssr_hmr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
FROM ruby:3.1.2 | ||
|
||
# Install Node.js | ||
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - | ||
RUN apt-get install -y nodejs | ||
|
||
# Install yarn version 3.2.1 | ||
RUN node -v && npm i -g yarn && yarn set version 3.2.1 | ||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Install foreman to leverage Procfile | ||
RUN gem install foreman | ||
|
||
# Copy node package maps | ||
COPY .yarnrc.yml package.json yarn.lock /app/ | ||
COPY .yarn/ /app/.yarn/ | ||
|
||
COPY Gemfile* /app | ||
# Install Gemfile | ||
RUN bundle install | ||
|
||
# Install node modules | ||
RUN yarn install | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app | ||
|
||
# Expose the rails app to outside the container | ||
EXPOSE 3000 | ||
|
||
# Expose hmr server to outside the container | ||
EXPOSE 3035 | ||
|
||
# Run the app when the container launches | ||
CMD ["foreman", "start", "-f", "Procfile.dev"] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Procfile for development using HMR | ||
# You can run these commands in separate shells | ||
rails: bundle exec rails s -p 3000 | ||
rails: bundle exec rails s -b 0.0.0.0 -p 3000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enable accepting requests from outside the container, like from the browser. |
||
wp-client: bin/shakapacker-dev-server | ||
wp-server: SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
rails: | ||
build: . | ||
image: ror_ssr_hmr:1.0.0 | ||
volumes: | ||
- node_modules:/app/node_modules | ||
- .:/app | ||
ports: | ||
- 3000:3000 | ||
- 3035:3035 | ||
|
||
volumes: | ||
node_modules: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ development: | |
# Reference: https://webpack.js.org/configuration/dev-server/ | ||
dev_server: | ||
https: false | ||
host: localhost | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For truly remote, such as CodeSpaces, one might also need to change the allowed list below |
||
host: 0.0.0.0 | ||
port: 3035 | ||
# Hot Module Replacement updates modules while the application is running without a full reload | ||
hmr: true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be configured differently, but it is likely a good idea to try to run both bare metal and containers through the same commands to avoid the need to update in multiple places when change comes.