Skip to main content

Posts

Showing posts with the label ror

how to setup rails with docker on ubuntu ?

I am assuming that you already know about rails and also have setup docker on your system Create sample app and change directory rails new sample-app cd sample-app Create Dockerfile FROM ruby : 2.5 RUN apt-get update -qq && apt-get install -y nodejs postgresql-client WORKDIR /sampe-app COPY Gemfile /sampe-app/Gemfile COPY Gemfile.lock /sample-app/Gemfile.lock RUN bundle install COPY . /sampe-app COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT [ "entrypoint.sh" ] EXPOSE 3000 CMD [ "rails" , "server" , "-b" , "0.0.0.0" ] Create entrypoint.sh #!/bin/bash set -e # remove potentiallly pre existing server.pid for rails rm -f /sample-app/tmp/pids/server.pid # execute the docker containers main process exec " $@ " Create docker-compose.yml version : "3.9" services : db : image : postgres volumes : - ./tmp/db:/var/lib/postgresql/data envir...