Book Image

Infrastructure as Code (IAC) Cookbook

By : Stephane Jourdan, Pierre Pomès
Book Image

Infrastructure as Code (IAC) Cookbook

By: Stephane Jourdan, Pierre Pomès

Overview of this book

Para 1: Infrastructure as code is transforming the way we solve infrastructural challenges. This book will show you how to make managing servers in the cloud faster, easier and more effective than ever before. With over 90 practical recipes for success, make the very most out of IAC.
Table of Contents (18 chapters)
Infrastructure as Code (IAC) Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Testing Docker containers with BATS


BATS (Bash Automated Testing System) allows you to have quick and easy tests in a very natural language, without the need of a lot of dependencies. BATS can also grow in complexity as per your requirement. In this section, we'll use Docker with Docker Compose to handle the build and a Makefile to tie the dependencies between the build process and the BATS testing process; this will make it easier to later integrate this process into a CI system.

Getting ready

To step through this recipe, you will need:

  • A working Docker installation

  • A BATS installation (it's available for all major Linux distributions and Mac OS)

Note

BATS Version 0.4.0 is used in this chapter.

How to do it…

Let's start with this simple Dockerfile that will install Apache and run it after clearing the cache:

FROM debian:stable-slim
LABEL name="apache"
LABEL maintainer="John Doe <[email protected]>"
LABEL version=1.0
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends...