Skip to content

djalal/dockerfail

Repository files navigation

Dockerfail to Dockerfile

Purpose

This is the demo repository for the talk "From Dockerfail to Dockerfile". It is based on the wordsmith repository. The purpose is to show how teams can start from minimal dockerized app to a production-ready deployment.

Disclaimer: the code is intentionally left agnostic to tools and vendors, and is NOT suited for production use.

Code is divided in 11 folders, each bringing an improvement on the previous one.

  1. minimal viable container running wordsmith demo
  2. syntaxic check of Dockerfile with hadolint
  3. semantic checks of resulting Docker image with container-structure-test
  4. speed and network gains with cache good practices
  5. security and image size fixes with multi stage Dockerfile
  6. storing secrets away from code
  7. auditable track of dependencies
  8. increasing resiliency with healthchecks
  9. splitting demo app in multi-container deployment
  10. signing images to enforce trusted origin
  11. doing it all without Docker tooling

Requirements

  • shell
  • docker 20+
  • a docker hub account to push images (free)
  • ggshield (client with valid API key)
  • snyk (connected via docker scan --login)

Configuration

rename/copy .env-dist to .env

open .env to complete configuration

export GITGUARDIAN_API_KEY=<xyz>
export REGISTRY=dockerfail

Apple M1 Chip: you need to force platform type like this: export DOCKER_DEFAULT_PLATFORM=linux/arm64

Usage

  1. choose between on of the 10 "dockerfails" to run the demo:
cd <dockerfail folder>
./build-ship-run.sh
  1. check running containers
docker ps
OR
docker service ls
  1. study diffs from one stage to the other folders to understand how each step fixes the previous defect. For instance:

diff 00-base 01-hadolint

Todo

  • set image tags by content and not by timestamp
  • set labels on all resources to clean more easily

Contributing

There are more Dockerfails out there! If you feel like contributing, feel free to submit a PR.

License

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.