-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from autopilotpattern/wip
WIP
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} |