Chuan Chuan Law

DevOps | Software Automation | Continuous Integration

Tag: tiller

Docker – Using Tiller To Overwrite Environment Specific Variables

To use Tiller, in Dockerfile, we specify:

ADD deploy/tiller/*.yaml /etc/tiller/
ADD deploy/tiller/environments/dev /etc/tiller/environments/
ADD deploy/tiller/templates/* /etc/tiller/templates/

Tiller folder comprises of the following:

  • environments

This is where the yaml for environment specific variables are written:

#These are the variables to overwrite service.conf.erb template

service.conf.erb:
target: /etc/appleapi/application.ini
config:
environment_name: “prod”

#These are the variables to overwrite template.conf.erb template

template.conf.erb:
target: /etc/appleapi/application.conf

#database
appleapi_database_url: jdbc:postgresql://appledb:5432/appleapi
deliveryapi_database_user: apple
deliveryapi_database_password: apple

  • templates

There are the files in the server to be overwritten:

# PostgreSQL configuration (default datasource)
db.default.driver=org.postgresql.Driver
db.default.url=”<%=appleapi_database_url%>”
db.default.username=”<%=appleapi_database_user%>”
db.default.password=”<%=appleapi_database_password%>”

  • common.yaml

data_sources: [ “defaults” , “file” , “environment” ]
template_sources: [ file ]
deep_merge: true

Load the defaults, file and then environment data source to overwrite the templates

  • default.yaml

global:
application_name: “appleapi”
application_port: 9001

Default variables that are shared regardless of environment

Run it in Dockerfile:

RUN tiller -b /etc/tiller -n -v -e production

Docker – How To Run A Debian Package In Docker

Below are the major steps on how to run a Debian package in Docker

Dockerfile
  • Download your Debian file

# Download .deb fileRUN wget $debian_url \
&& sudo dpkg -i appleapi.deb \
&& apt-get install -f

  • Using Ruby Tiller to overwrite environment specific configs (optional)

#Tiller
RUN sudo apt-get update && sudo apt-get -y install ruby
RUN gem install tiller

ADD deploy/tiller/*.yaml /etc/tiller/
ADD deploy/tiller/environments/dev /etc/tiller/environments/
ADD deploy/tiller/templates/* /etc/tiller/templates/

  • Run Tiller and tell it to use development environment configuration

RUN tiller -b /etc/tiller -n -v -e development

  • Expose the port of your app

EXPOSE 9001

  • Start your app via Supervisord (optional as you could just use CMD)

CMD [“/usr/bin/supervisord”]

  • Build the Docker file

docker build  -t appleapi .

  • Run Docker in localhost

docker run -p 9001:9001 appleapi

supervisord.conf

[supervisord]
nodaemon=true

[program:appleapi]
startsecs = 0
autorestart = false
command=/bin/bash -c “appleapi/bin/appleapi”

© 2019 Chuan Chuan Law

Theme by Anders NorenUp ↑