Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Init] Dockerfile & docker-compose.yml #578

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Init] Dockerfile & docker-compose.yml
  • Loading branch information
henarcol committed Dec 29, 2023
commit 12ab1d12d9eeac510efc5a1774e3f80ba6d8414e
34 changes: 34 additions & 0 deletions Dockerfile
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 4 additions & 1 deletion Gemfile
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -112,3 +112,6 @@ end

gem "stimulus-rails", "~> 1.2"
gem "turbo-rails", "~> 1.4"

gem "mysql2"
gem "error_highlight"
4 changes: 2 additions & 2 deletions Procfile.dev
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions config/database.yml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.1.0",
"description": "Code from the React Webpack tutorial.",
"engines": {
"node": "18",
"node": "20",
"yarn": "1.22"
},
"repository": {
Expand Down

AltStyle によって変換されたページ (->オリジナル) /