1.8 KiB
Exercise — writing Dockerfiles
Let's write Dockerfiles for an existing application!
-
Check out the code repository
-
Read all the instructions
-
Write Dockerfiles
-
Build and test them individually
Code repository
Clone the repository available at:
https://github.com/jpetazzo/wordsmith
It should look like this:
├── LICENSE
├── README
├── db/
│ └── words.sql
├── web/
│ ├── dispatcher.go
│ └── static/
└── words/
├── pom.xml
└── src/
Instructions
The repository contains instructions in English and French.
For now, we only care about the first part (about writing Dockerfiles).
Place each Dockerfile in its own directory, like this:
├── LICENSE
├── README
├── db/
│ ├── `Dockerfile`
│ └── words.sql
├── web/
│ ├── `Dockerfile`
│ ├── dispatcher.go
│ └── static/
└── words/
├── `Dockerfile`
├── pom.xml
└── src/
Build and test
Build and run each Dockerfile individually.
For db, we should be able to see some messages confirming that the data set
was loaded successfully (some INSERT lines in the container output).
For web and words, we should be able to see some message looking like
"server started successfully".
That's all we care about for now!
Bonus question: make sure that each container stops correctly when hitting Ctrl-C.
???
Test with a Compose file
Place the following Compose file at the root of the repository:
version: "3"
services:
db:
build: db
words:
build: words
web:
build: web
ports:
- 8888:80
Test the whole app by bringin up the stack and connecting to port 8888.