Skip to content

Commit 5753482

Browse files
committed
Initial commit
0 parents  commit 5753482

7 files changed

Lines changed: 123 additions & 0 deletions

File tree

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: generic
2+
branches:
3+
only:
4+
- master
5+
sudo: required
6+
services:
7+
- docker
8+
install:
9+
- make docker-build
10+
script:
11+
- make test-style

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Short name: Short name, following [a-zA-Z_], used all over the place.
2+
# Some uses for short name:
3+
# - Docker image name
4+
# - Kubernetes service, rc, pod, secret, volume names
5+
SHORT_NAME := redis
6+
DEIS_REGISTY ?= ${DEV_REGISTRY}/
7+
IMAGE_PREFIX ?= deis
8+
9+
include versioning.mk
10+
11+
SHELL_SCRIPTS = $(wildcard _scripts/*.sh) rootfs/bin/boot
12+
13+
# The following variables describe the containerized development environment
14+
# and other build options
15+
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.11.0
16+
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
17+
DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
18+
DEV_ENV_CMD_INT := docker run -it --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
19+
20+
all: docker-build docker-push
21+
22+
dev:
23+
${DEV_ENV_CMD_INT} bash
24+
25+
# For cases where we're building from local
26+
# We also alter the RC file to set the image name.
27+
docker-build:
28+
docker build --rm -t ${IMAGE} rootfs
29+
docker tag -f ${IMAGE} ${MUTABLE_IMAGE}
30+
31+
test: test-style test-unit test-functional
32+
33+
test-style:
34+
${DEV_ENV_CMD} shellcheck $(SHELL_SCRIPTS)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Deis Redis

_scripts/deploy.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build and push Docker images to Docker Hub and quay.io.
4+
#
5+
6+
cd "$(dirname "$0")" || exit 1
7+
8+
export IMAGE_PREFIX=deisci
9+
docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
10+
DEIS_REGISTRY='' make -C .. docker-build docker-push
11+
docker login -e="$QUAY_EMAIL" -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io
12+
DEIS_REGISTRY=quay.io/ make -C .. docker-build docker-push

rootfs/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM quay.io/deis/base:0.3.0
2+
3+
COPY . /
4+
5+
RUN apt-get update \
6+
&& apt-get install -y redis-server \
7+
--no-install-recommends \
8+
&& apt-get clean \
9+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc \
10+
&& chown -R redis:redis /etc/redis /var/lib/redis /var/log/redis
11+
12+
USER redis
13+
WORKDIR /var/lib/redis
14+
15+
CMD ["/bin/boot"]
16+
EXPOSE 6379
17+
18+
ENV WORKFLOW_RELEASE 2.1.0

rootfs/bin/boot

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -eof pipefail
4+
5+
REDIS_CONFIG_FILE=/etc/redis/redis.conf
6+
7+
# Do not daemonize
8+
sed -i "s/daemonize yes/daemonize no/" $REDIS_CONFIG_FILE
9+
10+
# Bind to 0.0.0.0
11+
sed -i "s/bind 127.0.0.1/bind 0.0.0.0/" $REDIS_CONFIG_FILE
12+
13+
# Log to stdout
14+
sed -i "s:logfile /var/log/redis/redis-server.log:logfile \"\":" $REDIS_CONFIG_FILE
15+
16+
# Set password
17+
REDIS_PASSWORD_FILE=/var/run/secrets/deis/redis/creds/password
18+
if [ -e $REDIS_PASSWORD_FILE ]; then
19+
REDIS_PASSWORD="$(cat /var/run/secrets/deis/redis/creds/password)"
20+
if [ ! -z "$REDIS_PASSWORD" ]; then
21+
sed -i "s/# requirepass foobared/requirepass $REDIS_PASSWORD/" $REDIS_CONFIG_FILE
22+
fi
23+
fi
24+
25+
exec redis-server $REDIS_CONFIG_FILE

versioning.mk

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MUTABLE_VERSION ?= canary
2+
VERSION ?= git-$(shell git rev-parse --short HEAD)
3+
4+
IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
5+
MUTABLE_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION}
6+
7+
info:
8+
@echo "Build tag: ${VERSION}"
9+
@echo "Registry: ${DEIS_REGISTRY}"
10+
@echo "Immutable tag: ${IMAGE}"
11+
@echo "Mutable tag: ${MUTABLE_IMAGE}"
12+
13+
.PHONY: docker-push
14+
docker-push: docker-immutable-push docker-mutable-push
15+
16+
.PHONY: docker-immutable-push
17+
docker-immutable-push:
18+
docker push ${IMAGE}
19+
20+
.PHONY: docker-mutable-push
21+
docker-mutable-push:
22+
docker push ${MUTABLE_IMAGE}

0 commit comments

Comments
 (0)