# syntax = docker/dockerfile:1 FROM node:slim as build RUN apt-get update &&\ apt-get install -y autoconf bison patch build-essential \ libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev \ libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev uuid-dev \ git curl &&\ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y &&\ export PATH=/root/.cargo/bin:$PATH &&\ git clone https://github.com/rbenv/ruby-build.git /opt/ruby-build &&\ /opt/ruby-build/install.sh &&\ ruby-build 3.2.0 /usr/local RUN gem install rails RUN rails new demo --skip-active-record --javascript esbuild WORKDIR demo RUN yarn add react react-dom FROM node:slim WORKDIR demo COPY --from=build /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu COPY --from=build /usr/local /usr/local COPY --from=build /demo /demo RUN bin/rails generate controller Time index RUN cat <<-"EOF" >> app/javascript/application.js import "./components/counter" EOF RUN mkdir app/javascript/components COPY <<-"EOF" app/javascript/components/counter.jsx import React, { useState, useEffect, useRef } from 'react'; import { createRoot } from 'react-dom/client'; const Counter = ({ arg }) => { const [count, setCount] = useState(0); const countRef = useRef(count); countRef.current = count; useEffect(() => { const interval = setInterval(() => { setCount(countRef.current + 1); }, 1000); return () => clearInterval(interval); }, []); return