Giter Club home page Giter Club logo

circle-docker-delivery's Introduction


An example of leveraging docker throughout your entire development process. Delivering a consistent environment while maintaining the benefits of tooling and a minimal production image.

Motivation

This repository demonstrates shipping a consistent build, development & continuous integration environment through multi-stage builds. You can leverage this pattern to ship a minimal release artefact - this offers benefits when it comes to elastic workloads.

The stages are tested to demonstrate a simple preventative measure against bad releases.

The build, test & release of the containers is conducted within CircleCI (but could easily be implemented elsewhere). The build/test phases are only performed given changes to the relevant files, saving continuous integration resources. Consult .circleci/config.yml for more detail.

If you implemented this in production, you'd use the CI stage to run your tests & build your source artefacts (source code). You would copy the output (transpiled etc.) into the release container & deploy it.

Benefits

At this point you've built, tested & developed your project against a base runtime - with all the benefits of additional tooling. You've then gone on to run the application - against the same base runtime - without having to recompile/link it. If you had expensive compilation steps during dependency installation for example, such as compiling native extensions for database adapters - you'd avoid having to run these twice while still delivering a minimal artefact.

Components

Dockerfile Hierarchy

                                          
+-------------------+                     +-----------------+
| Name: Project     |                     | Name: Rel       |
| Deps: Spec tools  |                     | Deps: Artefact  |
+-------------------+                     +--------+--------+
+-------------------+ +------------------+         ^
| Name: Dev         | | Name: CI         |         |
| Deps: QoL tooling | | Deps: TBD        +---------+
+-------------------+ +------------------+         |
                                                   |
+----------------------------------------+         |
| Name: Build                            |         |
| Deps: Build Tooling, Test Deps         |         |
+----------------------------------------+         |
                                                   |
+--------------------------------------------------+--------+
| Name: Base                                                |
| Deps: Runtime, Package Manager, Sys Deps, OS              |
+-----------------------------------------------------------+

Testing

Goss is used to assert that the critical components of the container layers remain intact.

You can target any layer you want by adding a goss.{layer_name}.yaml file with the desired assertions.

Convenience helpers for running the tests locally should be added to the root package.json run scripts. Examples include "test:base-container": "npm run test-container -- base"

Developing Container Tests
  1. Build the target layer wrapped in the goss test instructions (execute this from the repo root)

TARGET_LAYER=[ci|dev|build|release] or any stage in the multi-stage hierarchy you wish to test

docker build -t developing-goss --build-arg TARGET_TEST_LAYER=$TARGET_LAYER -f docker/Dockerfile . --target=test

  1. Launch into the target layer via dgoss

dgoss edit developing-goss

Inspect the goss.yaml copied out at the end of this process. More details can be found in the dgoss documentation.

Further Reading

Testing Strategies for Docker Containers

circle-docker-delivery's People

Contributors

dombo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.