Skip to content

Commit be2ee77

Browse files
authored
Merge pull request #1 from quay/init
initial import for Open Source 🎉
2 parents 3757995 + 175a219 commit be2ee77

35 files changed

+3056
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/*

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor/*
2+
.idea
3+
/bin/
4+
_vendor*
5+
*.test

Dockerfile.alpine

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM golang:1.12-alpine3.9 as build
2+
3+
ARG BUILDER_SRC=github.com/quay/quay-builder
4+
RUN apk --no-cache add build-base git
5+
COPY . /go/src/${BUILDER_SRC}
6+
RUN cd /go/src/${BUILDER_SRC} && make && make install
7+
8+
################################################################################
9+
10+
FROM alpine:3.9
11+
12+
RUN apk --no-cache upgrade # 2019-03-19
13+
14+
RUN apk --no-cache add --virtual .runtime-deps \
15+
ca-certificates git openssh-client perl
16+
17+
COPY --from=build /go/bin/quay-builder /usr/local/bin
18+
19+
COPY buildpack/ssh-git.sh /
20+
ADD load_extra_ca.alpine.sh /load_extra_ca.sh
21+
ADD entrypoint.sh /entrypoint.sh
22+
23+
VOLUME ["/tmp"]
24+
VOLUME [ "/certs" ]
25+
26+
ENTRYPOINT ["sh", "/entrypoint.sh"]

Dockerfile.rhel7

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM centos:7 AS build
2+
LABEL maintainer "Sida Chen <[email protected]>"
3+
4+
# Install Golang by retrieving the binary
5+
ENV GO_VERSION=1.12.1
6+
ENV GO_OS=linux
7+
ENV GO_ARCH=amd64
8+
ENV GO_HASH=2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec
9+
RUN curl https://dl.google.com/go/go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz --output go.tar.gz
10+
RUN echo ${GO_HASH} go.tar.gz > GOCHECKSUM
11+
RUN sha256sum -c GOCHECKSUM
12+
RUN tar -C /usr/local -xzf go.tar.gz > /dev/null
13+
ENV GOPATH=/go
14+
ENV PATH=$PATH:/usr/local/go/bin:${GOPATH}/bin
15+
16+
# Verify go verion
17+
RUN go version
18+
19+
ARG BUILDER_SRC=github.com/quay/quay-builder
20+
21+
# Install dependencies
22+
RUN yum install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git perl wget make gcc
23+
24+
COPY . /go/src/${BUILDER_SRC}
25+
RUN cd /go/src/${BUILDER_SRC} && make && make install
26+
27+
FROM registry.redhat.io/rhel7:7.6
28+
LABEL maintainer "[email protected]"
29+
30+
ARG SUBSCRIPTION_KEY
31+
RUN test -n "$SUBSCRIPTION_KEY" # Subscription key is required
32+
33+
# Install subscription key
34+
ADD ${SUBSCRIPTION_KEY} /tmp/
35+
RUN subscription-manager import --certificate=/tmp/${SUBSCRIPTION_KEY}
36+
RUN rm -f /tmp/${SUBSCRIPTION_KEY}
37+
38+
RUN yum install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git perl
39+
40+
# Remove subscription key
41+
RUN subscription-manager remove --all
42+
43+
COPY --from=build /go/bin/quay-builder /usr/local/bin
44+
45+
COPY buildpack/ssh-git.sh /
46+
ADD load_extra_ca.rhel.sh /load_extra_ca.sh
47+
ADD entrypoint.sh /entrypoint.sh
48+
49+
VOLUME ["/tmp"]
50+
VOLUME [ "/certs" ]
51+
52+
ENTRYPOINT ["sh", "/entrypoint.sh"]
53+

Makefile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.PHONY: dep test bin/quay-builder
2+
3+
PROJECT ?= quay-builder
4+
ORG_PATH ?= github.com/quay
5+
REPO_PATH ?= $(ORG_PATH)/$(PROJECT)
6+
IMAGE ?= quay.io/quay/$(PROJECT)
7+
VERSION ?= $(shell ./scripts/git-version)
8+
LD_FLAGS ?= "-w -X $(REPO_PATH)/version.Version=$(VERSION)"
9+
IMAGE_TAG ?= latest
10+
SUBSCRIPTION_KEY ?= subscription.pem
11+
12+
all: dep test build
13+
14+
dep:
15+
@GO111MODULE=on go mod vendor
16+
17+
test: dep
18+
@go vet ./...
19+
@go test -v ./...
20+
21+
build: dep bin/quay-builder
22+
23+
bin/quay-builder:
24+
@go build -ldflags $(LD_FLAGS) -o bin/quay-builder \
25+
$(REPO_PATH)/cmd/quay-builder
26+
27+
install:
28+
@go install -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/quay-builder
29+
30+
build-rhel7:
31+
docker build --squash -f Dockerfile.rhel7 -t $(IMAGE):$(IMAGE_TAG)-rhel7 . \
32+
--build-arg SUBSCRIPTION_KEY=$(SUBSCRIPTION_KEY)
33+
34+
build-alpine:
35+
docker build -f Dockerfile.alpine -t $(IMAGE):$(IMAGE_TAG)-alpine .

README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Quay Builder
2+
3+
This repository is for an automated build worker for a Quay.
4+
5+
## Architecture
6+
7+
There is a client/server relationship between builder and the management server.
8+
Clients connect using a standard websocket RPC/pubsub subprotocol called [WAMP](http://wamp.ws).
9+
There are two modes in which builders can operate: enterprise and hosted.
10+
Enterprise builders are designed to be long-running processes on the given machine that will be trusted forever.
11+
In this mode a builder connect to a Build Manager and indefinitely loop completing available work.
12+
Hosted builders are designed to be dynamically created and connect to the management server for a single build and then disappear.
13+
14+
## Building the builder
15+
16+
```
17+
make test
18+
make build
19+
```
20+
21+
## Running the builder
22+
23+
### Enterprise
24+
25+
Only an endpoint is required as all other parameters for building are acquired from a Build Manager on a per build basis.
26+
27+
```sh
28+
ENDPOINT="ws://localhost:8787" ./quay-builder
29+
```
30+
31+
### Hosted
32+
33+
A token and realm must be provided at launch in order to identify a particular build or else it will be rejected by a Build Manager.
34+
35+
```sh
36+
TOKEN="sometoken" ENDPOINT="ws://localhost:8787" REALM="builder-realm" ./quay-builder
37+
```
38+
39+
## Building the builder image
40+
41+
For both images, you can also specify make parameters
42+
43+
`IMAGE_TAG` ( tag name, default to `latest`)
44+
45+
`IMAGE` ( repo name, default to `quay.io/quay/quay-builder`)
46+
47+
and the built image will be tagged with
48+
```
49+
<IMAGE>:<IMAGE_TAG>-<base image name>
50+
```
51+
where the `<base image name>` can be either `alpine` or `rhel7`.
52+
53+
### Building Alpine based image:
54+
```sh
55+
make build-alpine-image
56+
```
57+
This generates image with tag `quay.io/quay/quay-builder:latest-alpine`.
58+
59+
### Building RHEL based image
60+
It requires certificate key and requires enabling `--squash` experimental feature
61+
```sh
62+
make build-rhel7-image SUBSCRIPTION_KEY=<path to your key file (PEM)>
63+
```
64+
This generates image with tag `quay.io/quay/quay-builder:latest-rhel7`.
65+
66+
## Running the builder image
67+
68+
Running alpine based image or rhel based image requires the same parameters but different image.
69+
70+
**Please Notice** that quay builder uses the host machine's docker.sock to pull/push/build images and therefore, the docker machine must be able to reach the Quay host. You can debug by pushing a image to quay instance.
71+
72+
### Pointing to Quay without TLS
73+
```
74+
docker run --restart on-failure -e SERVER=ws://myquayserver:8787 -v /var/run/docker.sock:/var/run/docker.sock quay.io/quay/quay-builder:latest-alpine
75+
```
76+
77+
### Pointing to Quay with TLS
78+
```
79+
docker run --restart on-failure -e SERVER=wss://myquayserver:8787 -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/customCA/rootCA.pem:/certs/rootCA.pem quay.io/quay/quay-builder:latest-alpine
80+
```

0 commit comments

Comments
 (0)