This sets up a Ruby on Rails 6.0.2 app using Docker and Docker-Compose to pull in docker images of Ruby 2.7.0 and MySQL 5.7.25.
-
Clone this repo
git clone https://github.com/dangxuanphuc/books4u.git
-
cd into the new directory
cd books4u
-
Update the Dockerfile and docker-compose.yml
#base image to build upon FROM ruby:2.7.0 RUN apt-get update && apt-get install -y build-essential RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -y nodejs RUN mkdir -p /app WORKDIR /app COPY Gemfile Gemfile.lock package.json yarn.lock ./ RUN gem install bundler -v "2.1.2" && bundle install --jobs 20 --retry 5 RUN npm install -g yarn RUN yarn install --check-files ADD ... COPY . ./ EXPOSE 3000
version: "3" services: db: image: mysql:5.7.25 environment: - MYSQL_ROOT_PASSWORD=123456 web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle install && bundle exec rails s -p 3000 -b '0.0.0.0'" tty: true stdin_open: true volumes: - .:/app ports: - "3000:3000" depends_on: - db phpmyadmin: image: phpmyadmin/phpmyadmin links: - db:mysql ports: - 8080:80
-
Rebuild docker image
docker-compose build
-
Start services
docker-compose up
-
If the Bash is part of your PATH, you can simply type "bash" and have a Bash terminal in your container
docker exec -it <container-name> /bin/bash
-
Reset database
rails db:migrate:reset
Here's how to get yourself set up to develop the app:
- Make sure you have Ruby 2.7 installed. Check with
ruby -v
. If you need to install or upgrade Ruby - Make sure you have Bundler installed: Try
bundle -v
and dogem install bundler
if needed. - Fork the repo at https://github.com/dangxuanphuc/books4u, then clone it with
git clone
. - Once you have the repo locally, you should be able to run
bundle
in the project directory, and it will install all the dependencies (including Rails 6.0.2 if you don't already have it). - After running the bundle, you will need to run
rails db:migrate
to add new tables to your database. You can start your app withrails server
and install your app by visitinghttp://localhost:3000
in your web browser.
- Fork it ( https://github.com/dangxuanphuc/books4u )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request