Skip to content

Commit 3a9734f

Browse files
author
Matthew
committed
fix up travis
1 parent a9422b0 commit 3a9734f

10 files changed

Lines changed: 100 additions & 27 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ branches:
88
services:
99
- docker
1010
install:
11-
- make build
11+
- make docker-build
1212
script:
1313
- make test
1414
deploy:
1515
provider: script
16-
script: contrib/ci/deploy.sh
16+
script: _scripts/ci/deploy.sh
1717
on:
1818
branch: master

Makefile

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,60 @@
11
include includes.mk
22

3-
# Short name, following [a-zA-Z_], used all over the place.
4-
SHORT_NAME := postgres
3+
# Short name: Short name, following [a-zA-Z_], used all over the place.
4+
# Some uses for short name:
5+
# - Docker image name
6+
# - Kubernetes service, rc, pod, secret, volume names
7+
SHORT_NAME := database
58

69
# SemVer with build information is defined in the SemVer 2 spec, but Docker
710
# doesn't allow +, so we use -.
8-
VERSION := 0.0.1-$(shell date "+%Y%m%d%H%M%S")
11+
VERSION := 0.1.0-$(shell date "+%Y%m%d%H%M%S")
912

1013
# Legacy support for DEV_REGISTRY, plus new support for DEIS_REGISTRY.
1114
DEIS_REGISTRY ?= ${DEV_REGISTRY}
1215

1316
IMAGE_PREFIX ?= deis/
1417

18+
# Kubernetes-specific information for RC, Service, and Image.
19+
RC := manifests/deis-${SHORT_NAME}-rc.tmp.yaml
20+
SVC := manifests/deis-${SHORT_NAME}-service.yaml
1521
IMAGE := ${DEIS_REGISTRY}/${IMAGE_PREFIX}${SHORT_NAME}:${VERSION}
1622

1723
all:
1824
@echo "Use a Makefile to control top-level building of the project."
1925

20-
build: docker-build
26+
build:
27+
@echo "Nothing to build. Use 'make docker-build' to build the image."
2128

29+
# For cases where we're building from local
30+
# We also alter the RC file to set the image name.
2231
docker-build: check-docker
2332
docker build --rm -t ${IMAGE} rootfs
2433

34+
# Push to a registry that Kubernetes can access.
2535
docker-push: check-docker check-registry
2636
docker push ${IMAGE}
2737

28-
test:
29-
@echo "No tests"
38+
# Deploy is a Kubernetes-oriented target
39+
deploy: kube-service kube-rc
3040

31-
.PHONY: all build
41+
# Some things, like services, have to be deployed before pods. This is an
42+
# example target. Others could perhaps include kube-secret, kube-volume, etc.
43+
kube-service: check-kubectl
44+
kubectl create -f ${SVC}
45+
46+
# When possible, we deploy with RCs.
47+
kube-rc: check-kubectl
48+
kubectl create -f ${RC}
49+
50+
kube-clean: check-kubectl
51+
kubectl delete rc deis-example
52+
53+
test: check-docker
54+
./_scripts/ci/test.sh ${IMAGE}
55+
56+
update-manifests:
57+
sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-database-rc.yaml \
58+
> manifests/deis-database-rc.tmp.yaml
59+
60+
.PHONY: all build kube-up kube-down deploy

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Postgres
1+
# Deis Database
22

33
A PostgreSQL database for use in the [Deis](http://deis.io) open source PaaS.
44

_scripts/ci/test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -eof pipefail
4+
set -x
5+
6+
JOB=$(docker run -d $1)
7+
# wait for postgres to boot
8+
sleep 4
9+
docker exec $JOB is_master
10+
docker rm -f $JOB

includes.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ check-kubectl:
1212

1313
check-registry:
1414
@if [ -z "$$DEIS_REGISTRY" ] && [ -z "$$DEV_REGISTRY" ]; then \
15-
echo "DEIS_REGISTRY is not exported"; \
16-
exit 2; \
15+
echo "DEIS_REGISTRY is not exported"; \
16+
exit 2; \
17+
fi

manifests/deis-database-rc.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: ReplicationController
3+
metadata:
4+
name: deis-database
5+
labels:
6+
app: deis-database
7+
heritage: deis
8+
spec:
9+
replicas: 1
10+
selector:
11+
app: deis-database
12+
heritage: deis
13+
template:
14+
metadata:
15+
labels:
16+
app: deis-database
17+
heritage: deis
18+
spec:
19+
containers:
20+
- name: deis-database
21+
image: quay.io/deisci/database:v2-alpha
22+
env:
23+
- name: POSTGRES_USER
24+
value: "deis"
25+
- name: POSTGRES_PASSWORD
26+
value: "changeme123"
27+
ports:
28+
- containerPort: 5432
29+
readinessProbe:
30+
exec:
31+
command:
32+
- is_master
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: deis-database
5+
labels:
6+
heritage: deis
7+
spec:
8+
ports:
9+
- port: 5432
10+
selector:
11+
name: deis-database
12+
heritage: deis

rootfs/Dockerfile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,11 @@ RUN apt-get update && apt-get install -y \
1313
--no-install-recommends \
1414
&& rm -rf /var/cache/apt/*
1515

16-
# add backup dir
17-
RUN mkdir -p /var/cache/postgresql/backups
18-
RUN chown -R postgres:postgres /var/cache/postgresql/backups
19-
2016
COPY . /
21-
22-
RUN chown -R postgres:postgres /app
23-
2417
WORKDIR /app
2518

26-
RUN pip install -r requirements.txt
19+
ENV PGDATA /app/data
2720

28-
USER postgres
29-
30-
RUN mkdir data
31-
32-
CMD ["python", "governor.py", "postgres.yml"]
21+
RUN pip install -r requirements.txt
3322

3423
ENV DEIS_RELEASE 2.0.0-dev

rootfs/bin/is_master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
set -e
55

66
# check if database is running
7-
pg_ctl status -D /app/data
7+
gosu postgres pg_ctl status -D $PGDATA
88

9-
QUERY=$(psql -Atc 'SELECT pg_is_in_recovery()')
9+
QUERY=$(gosu postgres psql -Atc 'SELECT pg_is_in_recovery()')
1010

1111
if [ "$QUERY" == "f" ]; then
1212
exit 0

0 commit comments

Comments
 (0)