diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..6259476fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM ruby:3.1-bullseye + +# Set working directory +WORKDIR /app + +# Copy Gemfile and install dependencies +COPY Gemfile Gemfile.lock ./ +RUN bundle install + +# RUN apt-get install mysql-client +RUN apt-get install -y curl \ + && curl -sL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y nodejs \ + && curl -L https://www.npmjs.com/install.sh | sh + +RUN apt-get install -y redis + +RUN npm install -g yarn + +# Copy application code +COPY . . + +RUN yarn +RUN yarn res:dev + +# Expose port 3000 +EXPOSE 3000 + +# Start the Rails server +# RUN rake db:setup + +# CMD ["rails", "server", "-b", "0.0.0.0"] +CMD [ "foreman", "start", "-f", "Procfile.dev" ] +# CMD ["ruby", "bin/dev"] \ No newline at end of file diff --git a/Gemfile b/Gemfile index ca55d2497..7917dbd3c 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.2" +ruby "3.1.4" gem "react_on_rails", "13.4.0" gem "shakapacker", "7.1.0" @@ -112,3 +112,6 @@ end gem "stimulus-rails", "~> 1.2" gem "turbo-rails", "~> 1.4" + +gem "mysql2" +gem "error_highlight" \ No newline at end of file diff --git a/Procfile.dev b/Procfile.dev index 20453bbe6..f17326e89 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,7 +1,7 @@ # Procfile for development using HMR # You can run these commands in separate shells -rescript: yarn res:dev +# rescript: yarn res:dev redis: redis-server -rails: bundle exec rails s -p 3000 +rails: bundle exec rails s -p 3000 -b 0.0.0.0 wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch diff --git a/config/database.yml b/config/database.yml index 816178c85..190c1d660 100644 --- a/config/database.yml +++ b/config/database.yml @@ -27,11 +27,14 @@ # Uncomment below for a setup with just postgres and change your Gemfile to reflect this default: &default - adapter: postgresql + adapter: mysql2 development: <<: *default - database: react-webpack-rails-tutorial + database: <%= ENV['DB_NAME'] %> + username: <%= ENV['DB_USER'] %> + password: <%= ENV['DB_PASSWD'] %> + host: <%= ENV['DB_HOST'] %> # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..510cbb6a6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3.9" +services: + app: + # run `docker build -t my-rails-app .` to build the image + image: my-rails-app + environment: + DB_NAME: db + DB_USER: root + DB_PASSWD: password + DB_HOST: host.docker.internal + ports: + - 3000:3000 + # I'm not using another container for the DB so commenting this + # db: + # image: postgres:alpine3.15 + # environment: + # POSTGRES_PASSWORD: example \ No newline at end of file diff --git a/package.json b/package.json index cf2fdaff1..bdbd48f7f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.1.0", "description": "Code from the React Webpack tutorial.", "engines": { - "node": "18", + "node": "20", "yarn": "1.22" }, "repository": {