Dockerfile.
1 FROM ruby:2.4.5
2 RUN apt-get update -qq && apt-get install -y build-essential nodejs
3 RUN mkdir /app
4 WORKDIR /app
5 COPY Gemfile /app/Gemfile
6 COPY Gemfile.lock /app/Gemfile.lock
7 RUN bundle install
8 COPY . /app
The part before 1: is called the repository. The part after: is called a tag. In this case, it shows the 2.4.5 tag of the ruby repository.
2 Defines a command to start a container from the image of ruby 2.4.5 and execute it in the container. I have installed build-essential nodejs with apt-get, ubuntu's package management system. Required for Rails to work
3 Create an app directory in the root directory
4 Move the working directory to the app directory
5,6 Copy Gemfile and Gemfilelock on your PC to the app directory
7 Execute the gem installation command
8 Copy the contents of the folder where the docker file is located to the app directory
docker file → build → docker image is created
Recommended Posts