Skip to content

Commit 894471a

Browse files
committed
Images: worker:beta, app-server:beta
1 parent b0bda1d commit 894471a

File tree

7 files changed

+179
-1
lines changed

7 files changed

+179
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
env/*
2+
worker/tmp/*
3+
app-server/tmp/*

Makefile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
go_version = go1.6.2.linux-amd64
2+
3+
go:
4+
5+
@echo "\033[1mInstall Go compiler\033[0m"
6+
7+
@[ -d env ] || mkdir env
8+
9+
@if [ ! -d env/go ]; then \
10+
cd env && \
11+
wget https://storage.googleapis.com/golang/$(go_version).tar.gz && \
12+
tar -xf ./$(go_version).tar.gz && \
13+
mkdir gopath && \
14+
rm ./$(go_version).tar.gz ; \
15+
fi
16+
17+
@GOROOT=$(shell pwd)/env/go \
18+
GOPATH=$(shell pwd)/env/gopath \
19+
env/go/bin/go get -u github.com/FiloSottile/gvt
20+
21+
@GOROOT=$(shell pwd)/env/go \
22+
GOPATH=$(shell pwd)/env/gopath \
23+
env/go/bin/go get -u github.com/kshvakov/build-html
24+
25+
@echo "\033[1mGo compiler installed!\033[0m"
26+
27+
build-worker:
28+
29+
@echo "\033[1mBuild Postgres-CI worker\033[0m"
30+
31+
@GOROOT=$(shell pwd)/env/go \
32+
GOPATH=$(shell pwd)/env/gopath \
33+
env/go/bin/go get -d -u github.com/postgres-ci/worker
34+
35+
@cd env/gopath/src/github.com/postgres-ci/worker && \
36+
$(shell pwd)/env/gopath/bin/gvt restore
37+
38+
@[ -d worker/tmp/ ] || mkdir worker/tmp/
39+
40+
@GOROOT=$(shell pwd)/env/go \
41+
GOPATH=$(shell pwd)/env/gopath \
42+
CGO_ENABLED=0 \
43+
env/go/bin/go build -ldflags='-s -w' -o worker/tmp/worker \
44+
env/gopath/src/github.com/postgres-ci/worker/worker.go
45+
46+
@echo "\033[1mBuild worker: done!\033[0m"
47+
48+
build-app-server:
49+
50+
@echo "\033[1mBuild Postgres-CI app-server\033[0m"
51+
52+
@GOROOT=$(shell pwd)/env/go \
53+
GOPATH=$(shell pwd)/env/gopath \
54+
env/go/bin/go get -d -u github.com/postgres-ci/app-server
55+
56+
@cd env/gopath/src/github.com/postgres-ci/app-server && \
57+
$(shell pwd)/env/gopath/bin/gvt restore
58+
59+
@rm -rf app-server/tmp/ && mkdir -p app-server/tmp/assets
60+
61+
@GOROOT=$(shell pwd)/env/go \
62+
GOPATH=$(shell pwd)/env/gopath \
63+
CGO_ENABLED=0 \
64+
env/go/bin/go build -ldflags='-s -w' -o app-server/tmp/app-server \
65+
env/gopath/src/github.com/postgres-ci/app-server/app-server.go
66+
67+
@cp -r env/gopath/src/github.com/postgres-ci/app-server/assets/static app-server/tmp/assets/static
68+
69+
@./env/gopath/bin/build-html -i env/gopath/src/github.com/postgres-ci/app-server/assets/templates_src -o app-server/tmp/assets/templates
70+
71+
@echo "\033[1mBuild app-server: done!\033[0m"
72+
73+
build-worker-image: build-worker
74+
75+
@echo "\033[1mBuild worker docker image\033[0m"
76+
77+
@cd worker && docker build -t postgresci/worker .
78+
79+
@echo "\033[1mBuild worker docker image: done!\033[0m"
80+
81+
build-app-server-image: build-app-server
82+
83+
@echo "\033[1mBuild app-server docker image\033[0m"
84+
85+
@cd app-server && docker build -t postgresci/app-server .
86+
87+
@echo "\033[1mBuild app-server docker image: done!\033[0m"
88+
89+
build: build-worker build-app-server
90+
91+
all: go build-worker-image build-app-server-image

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# docker-images
1+
# docker-images
2+
3+
4+
```
5+
docker run -d \
6+
--name postgres-ci-app-server \
7+
-e DB_HOST=172.16.9.131 \
8+
-e DB_USERNAME=postgres_ci \
9+
-e DB_PASSWORD=iAmAdiscoDancer \
10+
postgresci/app-server
11+
```
12+
13+
```
14+
docker run -d \
15+
--name postgres-ci-worker \
16+
-e DB_HOST=172.16.9.131 \
17+
-e DB_USERNAME=postgres_ci \
18+
-e DB_PASSWORD=iAmAdiscoDancer \
19+
-v /var/run/docker.sock:/var/run/docker.sock \
20+
-v /tmp/postgres-ci/builds/:/tmp/postgres-ci/builds/ \
21+
postgresci/worker
22+
```

app-server/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM nginx:stable-alpine
2+
3+
RUN rm -rf /etc/nginx/conf.d
4+
5+
COPY ./tmp/assets /opt/postgres-ci/assets
6+
COPY ./tmp/app-server /usr/local/bin/app-server
7+
COPY ./docker-entrypoint.sh /
8+
COPY etc/nginx/conf.d /etc/nginx/conf.d
9+
10+
ENV ADDRESS=127.0.0.1:8888 \
11+
TEMPLATES=/opt/postgres-ci/assets/templates/ \
12+
LOG_LEVEL=error \
13+
DB_PORT=5432 \
14+
DB_DATABASE=postgres_ci
15+
16+
ENTRYPOINT ["/docker-entrypoint.sh"]

app-server/docker-entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e
3+
4+
nginx -g "daemon on;" && /usr/local/bin/app-server "$@"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
3+
listen 80;
4+
access_log off;
5+
6+
gzip on;
7+
gzip_types text/plain text/css application/json application/x-javascript text/javascript application/javascript;
8+
9+
10+
location / {
11+
12+
proxy_pass http://127.0.0.1:8888;
13+
}
14+
15+
location = /favicon.ico {
16+
17+
expires max;
18+
19+
root /opt/postgres-ci/assets/static/;
20+
}
21+
22+
location /static/ {
23+
24+
expires max;
25+
26+
root /opt/postgres-ci/assets/;
27+
}
28+
}

worker/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM alpine:3.3
2+
3+
RUN apk update && apk add git && rm -rf /var/cache/apk/*
4+
5+
ENV ASSETS=/opt/postgres-ci/assets \
6+
WORKING_DIR=/tmp/postgres-ci/builds/ \
7+
NUM_WORKERS=auto \
8+
LOG_LEVEL=warning \
9+
DB_PORT=5432 \
10+
DB_DATABASE=postgres_ci \
11+
DOCKER_ENDPOINT=unix:///var/run/docker.sock
12+
13+
COPY ./tmp/worker /usr/local/bin/worker
14+
15+
ENTRYPOINT ["/usr/local/bin/worker"]

0 commit comments

Comments
 (0)