Category Archives: Supporting Scripts

Dockerfile for Apache Traffic Server (ATS)

Get Social!

Apache Traffic Server is an enterprise-grade proxy and caching server initially developed by Yahoo, then later made open source and managed by the Apache Foundation.

The below code is a Dockerfile that will download and build ATS on the latest Ubuntu base image. Currently, we’re using Apache Traffic Server version 8.0.5, but if you’d like to use a different version or check for a later version then you’ll need to replace the curl command with one of the downloads available from here.

Create a new folder on your Docker host and add the below text to the dockerfile.

mkdir ats
vi ats/dockerfile
FROM ubuntu:latest
# Update the package repository
RUN set -x \
 && DEBIAN_FRONTEND=noninteractive apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
        curl \
        locales \
        build-essential \
        bzip2 \
        libssl-dev \
        libxml2 \
        libxml2-dev \
        libpcre3 \
        libpcre3-dev \
        tcl \
        tcl-dev \
        libboost-dev \
    # Configure locale
 && export LANGUAGE=en_US.UTF-8 \
 && export LANG=en_US.UTF-8 \
 && export LC_ALL=en_US.UTF-8 \
 && locale-gen en_US.UTF-8 \
 && DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
    # Get ATS and build
    # http://www-eu.apache.org/dist/trafficserver/
RUN  mkdir /tmp/trafficserver \
 && cd /tmp/trafficserver \
 && curl -L http://www-eu.apache.org/dist/trafficserver/trafficserver-8.0.5.tar.bz2 | tar -xj --strip-components 1 \
 && ./configure \
 && make install \
 && make distclean \
 && cd / \
    # Clean-up
 && apt-get purge --auto-remove -y \
        curl \
        build-essential \
        bzip2 \
        libssl-dev \
        libxml2-dev \
        libpcre3-dev \
        tcl-dev \
        libboost-dev \
 && apt-get clean \
 && rm -rf /tmp/* /var/lib/apt/lists/*

RUN ln -s /usr/local/etc/trafficserver /etc/trafficserver
EXPOSE 8080

ENTRYPOINT ["/usr/local/bin/traffic_server"]

To build the Apache Traffic Server image, cd into the ats directory and issue the build command. The period (.) at the end of the build command is there on purpose – make sure you include it in your build command.

cd ats
docker build -t ats .

The build will take a few minutes, depending on your hardware, but will return you to the command line once completed.

Run your dockerfile and ATS will be available on port 8080, however, you’ll need to configure it as required. The config, such as remap.conf, is contained in /etc/trafficserver


gitignore file for Go Projects

Get Social!

This is a gitignore file for a Go project to ensure temporary files and build files are not added to git repository commits.

# Binaries, plugins, libs
*.dll
*.dylib
*.exe
*.exe~
*.so

# Testing
*.test
*.tmp

CockroachDB systemd script

Get Social!

This is a simple systemd script for CockroachDB. It works for single node installations or multiple nodes, however you’ll need to manually join each node to the cluster before using the systemd script. 

Create the systemd file and add the following content:

vi /etc/systemd/system/cockroach.service
[Unit]
Description=CockroachDB

[Install]
WantedBy=multi-user.target

[Service]
ExecStartPre=/bin/bash -c "test -f /etc/cockroachdb/hosts && (/bin/systemctl set-environment JOIN_SWITCH=--join=$(test -f /etc/cockroachdb/hosts && cat /dev/null /etc/cockroachdb/hosts)) || exit 0"
ExecStartPre=/bin/bash -c "test -f /etc/cockroachdb/host && (/bin/systemctl set-environment HOST_SWITCH=--host=$(test -f /etc/cockroachdb/host && cat /dev/null /etc/cockroachdb/host)) || exit 0"

ExecStart=/usr/local/bin/cockroach start --certs-dir=/etc/cockroachdb/certs \
                                         --store=/var/data/cockroachdb/ \
                                         --cache=.40 \
                                         --max-sql-memory=.30 \
                                         --external-io-dir=/tmp/cockroachdb/externalio \
                                         --temp-dir=/tmp/ \
                                         --port=26257 \
                                         --http-port=7005 \
                                         --logtostderr=ERROR \
                                         --log-dir=/var/logs/cockroachdb \
                                         $JOIN_SWITCH $HOST_SWITCH

ExecStop=/usr/local/bin/cockroach quit --certs-dir=/etc/cockroachdb/certs
SyslogIdentifier=cockroachdb
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
LimitNOFILE=35000

Note that there are several paths specified in the above file which may need to be tailored to your installation requirements.

Run the following to enable the service on system start, and to start the CockroachDB service.

systemctl enable cockroach # enable on startup
systemctl start cockroach  # start CockroachDB

If your host belongs to a cluster, create a hosts file containing the hosts of other nodes in your cluster that will be read when starting your local node. For multiple nodes, use a comma to separate each hostname and port combination.

vi /etc/cockroachdb/hosts
server1.jamescoyle.net:26257,server2.jamescoyle.net:26257

gitignore file for Eclipse Projects

Get Social!

This is an example of a .gitignore file for an Eclipse project to ensure temporary files, build files and project settings are not added to repository commits.

See .gitignore for more info.

# Jave related
target/**
*.jar
*.war
*.ear
*.class

# eclipse specific
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

gitignore file for Nodejs Projects

Tags :

Category : Supporting Scripts

Get Social!

An example gitignore file for Nodejs projects to ensure that local environment variables, build related output and modules are not committed to the git repository.

See .gitignore for more info.

# NodeJS specific #
.nyc_output/
coverage/
node_modules/
npm-debug.log
package-lock.json
test/*.log

gitignore file for Netbeans Projects

Tags :

Category : Supporting Scripts

Get Social!

A gitignore file for most Netbeans projects to keep the build and local configuration files out of your git repository.

See .gitignore for more info.

# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# Class Files #
*.class

# Package Files #
*.jar
*.war
*.ear

Visit our advertisers

Search

Quick Poll

Are you using Docker.io?

Visit our advertisers