August 2018
Intermediate to advanced
380 pages
10h 2m
English
Dockerfiles contain the descriptions of how a particular image must be built. We have two images: one is for the database, and the other one is for the backend. Let's start with the database image first:
FROM postgres:latestADD ./*.sql /docker-entrypoint-initdb.d/
The Docker file only contains two lines of code. First of all, we inherit from an existing image of Postgres. Second, we copy all of the SQL files from the current directory to a special directory in the Docker image. This is a standard initialization procedure described in the documentation of the Postgres image we inherit from. The main idea is to initialize the database with a schema that we are going to use. Our schema is as follows:
CREATE TABLE customer ( id serial ...