Skip to content

Commit 87fc655

Browse files
committed
Add Docker image, set up as a Marathon service
1 parent 12324cd commit 87fc655

File tree

8 files changed

+129
-16
lines changed

8 files changed

+129
-16
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
venv
2+
.tox
3+
debian

Dockerfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM docker.ocf.berkeley.edu/theocf/debian:jessie
2+
3+
RUN apt-get update \
4+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
5+
build-essential \
6+
cracklib-runtime \
7+
libcrack2-dev \
8+
libssl-dev \
9+
python3 \
10+
python3-dev \
11+
python3-pip \
12+
redis-tools \
13+
runit \
14+
spiped \
15+
sudo \
16+
virtualenv \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
RUN install -d --owner=nobody /opt/create /opt/create/venv
21+
22+
COPY requirements.txt /opt/create/
23+
RUN virtualenv -ppython3 /opt/create/venv \
24+
&& /opt/create/venv/bin/pip install pip==8.1.2 \
25+
&& /opt/create/venv/bin/pip install \
26+
-r /opt/create/requirements.txt
27+
28+
COPY etc/sudoers /etc/sudoers.d/create
29+
COPY create /opt/create/create
30+
31+
COPY services /opt/create/services
32+
RUN chown -R nobody:nogroup /opt/create
33+
USER nobody
34+
35+
WORKDIR /opt/create
36+
37+
CMD ["runsvdir", "/opt/create/services"]

Jenkinsfile

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
node('slave') {
2+
step([$class: 'WsCleanup'])
3+
4+
stage('check-out-code') {
5+
checkout scm
6+
}
7+
8+
stage('test') {
9+
sh 'make test'
10+
}
11+
12+
stage('test-cook-image') {
13+
sh 'make cook-image'
14+
}
15+
16+
stash 'build'
17+
}
18+
19+
20+
if (env.BRANCH_NAME == 'master') {
21+
def version = new Date().format("yyyy-MM-dd-'T'HH-mm-ss")
22+
withEnv([
23+
"DOCKER_REVISION=${version}",
24+
]) {
25+
node('slave') {
26+
step([$class: 'WsCleanup'])
27+
unstash 'build'
28+
29+
stage('cook-prod-image') {
30+
sh 'make cook-image'
31+
}
32+
33+
stash 'build'
34+
}
35+
36+
node('deploy') {
37+
step([$class: 'WsCleanup'])
38+
unstash 'build'
39+
40+
stage('push-to-registry') {
41+
sh 'make push-image'
42+
}
43+
44+
stage('deploy-to-prod') {
45+
build job: 'marathon-deploy-app', parameters: [
46+
[$class: 'StringParameterValue', name: 'app', value: 'create'],
47+
[$class: 'StringParameterValue', name: 'version', value: version],
48+
]
49+
}
50+
}
51+
}
52+
}
53+
54+
55+
// vim: ft=groovy

Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
DOCKER_REVISION ?= testing-$(USER)
2+
DOCKER_TAG = docker-push.ocf.berkeley.edu/create:$(DOCKER_REVISION)
3+
14
.PHONY: test
25
test: autoversion
36
pre-commit run --all-files
7+
pre-commit install -f --install-hooks
48

59
.PHONY: builddeb
610
builddeb: autoversion
@@ -17,6 +21,22 @@ autoversion:
1721
venv: autoversion vendor/venv-update requirements.txt setup.py
1822
vendor/venv-update venv= -ppython3.4 venv install= -r requirements.txt -e .
1923

24+
.PHONY: cook-image
25+
cook-image:
26+
# TODO: make ocflib version an argument
27+
docker build --pull -t $(DOCKER_TAG) .
28+
29+
.PHONY: push-image
30+
push-image:
31+
docker push $(DOCKER_TAG)
32+
33+
34+
.PHONY: dev
35+
dev: cook-image
36+
docker run --rm \
37+
-v /etc/ocf-create-new:/etc/ocf-create:ro \
38+
$(DOCKER_TAG)
39+
2040

2141
.PHONY: clean
2242
clean:

conf/ocf-create.conf

-16
This file was deleted.

etc/sudoers

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nobody ALL=(ALL) NOPASSWD: /usr/bin/install, /bin/ln, /usr/sbin/nscd

services/create/run

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -exo pipefail
3+
cd /opt/create
4+
. venv/bin/activate
5+
exec python -m create.worker

services/redis-tunnel/run

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
exec /usr/bin/spiped \
5+
-e -D -g -F -k /etc/ocf-create/create-redis.key \
6+
-p /dev/null \
7+
-s 127.0.0.1:6378 \
8+
-t create:6379

0 commit comments

Comments
 (0)