# syntax = docker/dockerfile:1 FROM ruby:slim as build RUN apt-get update &&\ apt-get install --yes build-essential git pkg-config redis libpq-dev RUN gem install rails RUN rails new demo --css tailwind --database postgresql FROM ruby:slim COPY --from=build /demo /demo COPY --from=build /usr/local/bundle /usr/local/bundle COPY --from=build /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ WORKDIR demo RUN bin/rails generate model Visitor counter:integer &&\ bin/rails generate channel counter COPY <<-"EOF" app/controllers/visitors_controller.rb class VisitorsController < ApplicationController def counter @visitor = Visitor.find_or_create_by(id: 1) @visitor.update! counter: @visitor.counter.to_i + 1 @visitor.broadcast_replace_later_to 'counter', partial: 'visitors/counter' end end EOF COPY <<-"EOF" app/views/visitors/counter.html.erb <%= turbo_stream_from 'counter' %>