Skip to content

Commit

Permalink
Merge pull request #1 from autopilotpattern/wip
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
misterbisson committed Apr 27, 2016
2 parents 4c32482 + 85a7bc3 commit 67c2801
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM memcached:latest

USER root
RUN apt-get update \
&& apt-get install -y \
netcat \
curl

# Install ContainerPilot
# Releases at https://github.com/joyent/containerpilot/releases
ENV CONTAINERPILOT_VER 2.0.1
RUN export CONTAINERPILOT_CHECKSUM=a4dd6bc001c82210b5c33ec2aa82d7ce83245154 \
&& curl -Lso /tmp/containerpilot.tar.gz \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VER}/containerpilot-${CONTAINERPILOT_VER}.tar.gz" \
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerpilot.tar.gz -C /usr/local/bin \
&& rm /tmp/containerpilot.tar.gz

# Add ContainerPilot configuration
COPY etc/containerpilot.json /etc/containerpilot.json
ENV CONTAINERPILOT file:///etc/containerpilot.json

# reset entrypoint from base image
ENTRYPOINT []
USER memcache
CMD ["/usr/local/bin/containerpilot", \
"memcached", \
"-l", \
"0.0.0.0"]
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
# memcached
# Autopilot memcached
*Containerized memcached server, based on the official memcached Docker image, adding [ContainerPilot](https://www.joyent.com/containerpilot) to announce this container's memcached service to a Service Discovery layer, such as Consul or etcd.

[![DockerPulls](https://img.shields.io/docker/pulls/autopilotpattern/memcached.svg)](https://registry.hub.docker.com/u/autopilotpattern/memcached/)
[![DockerStars](https://img.shields.io/docker/stars/autopilotpattern/memcached.svg)](https://registry.hub.docker.com/u/autopilotpattern/memcached/)
[![ImageLayers](https://badge.imagelayers.io/autopilotpattern/memcached:latest.svg)](https://imagelayers.io/?images=autopilotpattern/memcached:latest)
[![Join the chat at https://gitter.im/autopilotpattern/general](https://badges.gitter.im/autopilotpattern/general.svg)](https://gitter.im/autopilotpattern/general)

### Usage
Include this image in your Docker Compose project, query Consul for it's IP address and use it in your configurations, easily done via [Consul-Template](https://github.com/hashicorp/consul-template). The default ContainerPilot configuration talks to Consul and assumes the IP address to access consule is passed to the container in an envrionment varible, $CONSUL

Consider this example consul template from the [AutoPilot Wordpress](https://github.com/autopilotpattern/wordpress) project

```
# included into wp-config.php
{{ if service "memcached" }}
# turn on WP caching
define('WP_CACHE', true);
define( 'WP_APC_KEY_SALT', '{{env "WORDPRESS_CACHE_KEY_SALT"}}' );
define( 'WP_CACHE_KEY_SALT', '{{env "WORDPRESS_CACHE_KEY_SALT"}}' );
global $memcached_servers;
# write the address:port pairs for each healthy memcached node
$memcached_servers = array(
{{range service "memcached"}}
array(
'{{.Address}}',
{{.Port}}
),
{{end}}
);
{{ end }}
```
12 changes: 12 additions & 0 deletions etc/containerpilot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"consul": "{{ .CONSUL }}:8500",
"services": [
{
"name": "memcached",
"port": 11211,
"health": "nc -vz localhost 11211",
"poll": 10,
"ttl": 25
}
]
}

0 comments on commit 67c2801

Please sign in to comment.