Coder Social home page Coder Social logo

dc-check's Introduction

dc-check

Simple Go Template syntax checker for Rancher's docker-compose files

Introduction

Rancher allows to use Go's template engine for docker-compose files. If you develop for a Rancher catalog item you might want to check how your docker-compose files look like based on possible answers given when you deploy a service from the catalog.

But how can you check how your docker-compose file looks like without actually deploying it?

Rancher deploys your file regardless whether Go Template engine has fully comiled your file or not. What's more, it's hard to interprete Rancher deployment errors if your file has newline or indentation errors and you can't actually see the resulting code.

This is where dc-check comes into play. It will just print the resulting docker-compose file to the console. See examples below.

Build

go build -o dc-check

Examples

A common example is to make ports public available or to just expose them internally.

mini-compose.yml:

{{- if eq .Values.PLAINTEXT_PORT_PUBLIC "true" }}
  ports:
  - 80:8080/tcp
{{- else }}
  expose:
  - 8080/tcp
{{- end }}

Example 1:

Setup your environment:

export PLAINTEXT_PORT_PUBLIC=true

./dc-check mini-compose.yml

will result in:

ports:
- 80:8080/tcp

Example 2:

Setup your environment:

export PLAINTEXT_PORT_PUBLIC=true

./dc-check mini-compose.yml

will result in:

expose:
- 8080/tcp

More examples

More complex example with ports can be found in this repo which also works if no port is public at all:

. sample1.env && ./dc-check sample-compose.yml

version: '2'
services:
  myservice:
    image: ubuntu:latest
    ports:
    - ${SSL_PORT}:8443/tcp
    expose:
    - 8080/tcp
    environment:
      LOGLEVEL: ${LOGLEVEL}

. sample2.env && ./dc-check sample-compose.yml

version: '2'
services:
  myservice:
    image: ubuntu:latest
    expose:
    - 8080/tcp
    - 8443/tcp
    environment:
      LOGLEVEL: ${LOGLEVEL}

. sample3.env && ./dc-check sample-compose.yml

version: '2'
services:
  myservice:
    image: ubuntu:latest
    ports:
    - ${PLAINTEXT_PORT}:8080/tcp
    - ${SSL_PORT}:8443/tcp
    environment:
      LOGLEVEL: ${LOGLEVEL}

dc-check's People

Contributors

nerdicbynature avatar

Stargazers

 avatar  avatar  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.