Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Commit 26659fe

Browse files
authored
Merge pull request #1 from johnmcollier/bootstrapReg
Bootstrap the Red Hat product devfile registry
2 parents 809788e + 8c2576a commit 26659fe

File tree

9 files changed

+706
-0
lines changed

9 files changed

+706
-0
lines changed

.ci/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM quay.io/openshift-pipeline/golang:1.15-alpine AS builder
2+
3+
# Install dependencies
4+
5+
RUN apk add --no-cache git bash curl zip
6+
7+
# Install yq
8+
RUN curl -sL -O https://github.com/mikefarah/yq/releases/download/v4.9.5/yq_linux_amd64 -o /usr/local/bin/yq && mv ./yq_linux_amd64 /usr/local/bin/yq && chmod +x /usr/local/bin/yq
9+
10+
COPY . /registry
11+
12+
# Download the registry build tools
13+
RUN git clone https://github.com/devfile/registry-support.git /registry-support
14+
15+
# Run the registry build tools
16+
RUN /registry-support/build-tools/build.sh /registry /build
17+
18+
FROM quay.io/devfile/devfile-index-base:next
19+
20+
COPY --from=builder /build /registry
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
apiVersion: v1
3+
kind: Template
4+
metadata:
5+
name: devfile-registry-acceptance
6+
objects:
7+
- apiVersion: batch/v1
8+
kind: Job
9+
metadata:
10+
name: devfile-registry-acceptance-${JOB_NAME}
11+
spec:
12+
backoffLimit: 5
13+
template:
14+
spec:
15+
restartPolicy: Never
16+
containers:
17+
- image: ${IMAGE}:${IMAGE_TAG}
18+
imagePullPolicy: Always
19+
name: github-mirror-acceptance
20+
env:
21+
- name: REGISTRY
22+
value: ${REGISTRY}
23+
parameters:
24+
- name: IMAGE
25+
value: quay.io/devfile/devfile-registry-integration
26+
- name: IMAGE_TAG
27+
value: "next"
28+
required: true
29+
- name: REGISTRY
30+
value: "https://registry.stage.devfile.io"
31+
required: true
32+
- name: JOB_NAME
33+
generate: expression
34+
from: "[a-z0-9]{5}"

.ci/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# This script downloads the registry build tools and builds up this repository
3+
# This script runs on both the GitHub action CI and the CICD for the hosted registry
4+
5+
ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
7+
docker build --no-cache -t devfile-index -f $ABSOLUTE_PATH/Dockerfile $ABSOLUTE_PATH/..

.ci/build_and_deploy.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# This script downloads the registry build tools and builds up this repository then pushes it to quay.io
3+
# This will be run via the app-sre CI.
4+
set -ex
5+
ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
GIT_REV="$(git rev-parse --short=7 HEAD)"
7+
IMAGE="${IMAGE:-quay.io/app-sre/product-devfile-index}"
8+
IMAGE_TAG="${IMAGE_TAG:-${GIT_REV}}"
9+
10+
# Run the build script
11+
$ABSOLUTE_PATH/build.sh
12+
13+
# Push the iamge to quay.io
14+
if [[ -n "$QUAY_USER" && -n "$QUAY_TOKEN" ]]; then
15+
DOCKER_CONF="$PWD/.docker"
16+
mkdir -p "$DOCKER_CONF"
17+
docker tag devfile-index "${IMAGE}:${IMAGE_TAG}"
18+
docker tag devfile-index "${IMAGE}:next"
19+
docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
20+
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
21+
docker --config="$DOCKER_CONF" push "${IMAGE}:next"
22+
fi

.ci/deploy/devfile-registry.yaml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#
2+
# Copyright (c) 2021 Red Hat, Inc.
3+
# This program and the accompanying materials are made
4+
# available under the terms of the Eclipse Public License 2.0
5+
# which is available at https://www.eclipse.org/legal/epl-2.0/
6+
#
7+
# SPDX-License-Identifier: EPL-2.0
8+
#
9+
---
10+
apiVersion: v1
11+
kind: Template
12+
metadata:
13+
name: devfile-registry
14+
objects:
15+
- apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
labels:
19+
app: devfile-registry
20+
name: devfile-registry
21+
spec:
22+
replicas: ${{REPLICAS}}
23+
selector:
24+
matchLabels:
25+
app: devfile-registry
26+
strategy:
27+
type: RollingUpdate
28+
rollingUpdate:
29+
maxSurge: 25%
30+
maxUnavailable: 25%
31+
template:
32+
metadata:
33+
labels:
34+
app: devfile-registry
35+
spec:
36+
volumes:
37+
- name: devfile-registry-storage
38+
emptyDir: {}
39+
- name: config
40+
configMap:
41+
name: devfile-registry
42+
items:
43+
- key: registry-config.yml
44+
path: config.yml
45+
containers:
46+
- image: ${DEVFILE_INDEX_IMAGE}:${DEVFILE_INDEX_IMAGE_TAG}
47+
imagePullPolicy: "${DEVFILE_INDEX_PULL_POLICY}"
48+
name: devfile-registry
49+
ports:
50+
- containerPort: 8080
51+
livenessProbe:
52+
httpGet:
53+
path: /
54+
port: 8080
55+
initialDelaySeconds: 30
56+
periodSeconds: 10
57+
timeoutSeconds: 3
58+
readinessProbe:
59+
httpGet:
60+
path: /
61+
port: 8080
62+
initialDelaySeconds: 3
63+
periodSeconds: 10
64+
timeoutSeconds: 3
65+
resources:
66+
requests:
67+
cpu: 1m
68+
memory: 5Mi
69+
limits:
70+
cpu: 100m
71+
memory: ${DEVFILE_INDEX_MEMORY_LIMIT}
72+
- image: ${OCI_REGISTRY_IMAGE}:${OCI_REGISTRY_IMAGE_TAG}
73+
imagePullPolicy: "${OCI_REGISTRY_PULL_POLICY}"
74+
name: oci-registry
75+
livenessProbe:
76+
httpGet:
77+
path: /v2/
78+
port: 5000
79+
initialDelaySeconds: 30
80+
periodSeconds: 10
81+
timeoutSeconds: 3
82+
readinessProbe:
83+
httpGet:
84+
path: /v2/
85+
port: 5000
86+
initialDelaySeconds: 3
87+
periodSeconds: 10
88+
timeoutSeconds: 3
89+
resources:
90+
requests:
91+
cpu: 1m
92+
memory: 5Mi
93+
limits:
94+
cpu: 100m
95+
memory: ${OCI_REGISTRY_MEMORY_LIMIT}
96+
volumeMounts:
97+
- name: devfile-registry-storage
98+
mountPath: "/var/lib/registry"
99+
- name: config
100+
mountPath: "/etc/docker/registry"
101+
readOnly: true
102+
- apiVersion: v1
103+
kind: Service
104+
metadata:
105+
name: devfile-registry
106+
labels:
107+
app: devfile-registry
108+
spec:
109+
ports:
110+
- name: http
111+
protocol: TCP
112+
port: 8080
113+
targetPort: 8080
114+
- name: oci-metrics
115+
protocol: TCP
116+
port: 5001
117+
targetPort: 5001
118+
- name: index-metrics
119+
protocol: TCP
120+
port: 7071
121+
targetPort: 7071
122+
selector:
123+
app: devfile-registry
124+
- apiVersion: v1
125+
kind: ConfigMap
126+
metadata:
127+
name: devfile-registry
128+
annotations:
129+
qontract.recycle: "true"
130+
data:
131+
registry-config.yml: |
132+
version: 0.1
133+
log:
134+
fields:
135+
service: registry
136+
storage:
137+
cache:
138+
blobdescriptor: inmemory
139+
filesystem:
140+
rootdirectory: /var/lib/registry
141+
http:
142+
addr: :5000
143+
headers:
144+
X-Content-Type-Options: [nosniff]
145+
debug:
146+
addr: :5001
147+
prometheus:
148+
enabled: true
149+
path: /metrics
150+
151+
parameters:
152+
- name: DEVFILE_INDEX_IMAGE
153+
value: quay.io/app-sre/product-devfile-index
154+
displayName: Devfile registry index image
155+
description: Devfile registry index docker image. Defaults to quay.io/devfile/devfile-index
156+
- name: DEVFILE_INDEX_IMAGE_TAG
157+
value: next
158+
displayName: Devfile registry version
159+
description: Devfile registry version which defaults to next
160+
- name: DEVFILE_INDEX_MEMORY_LIMIT
161+
value: 256Mi
162+
displayName: Memory Limit
163+
description: Maximum amount of memory the container can use. Defaults 256Mi
164+
- name: DEVFILE_INDEX_PULL_POLICY
165+
value: Always
166+
displayName: Devfile registry image pull policy
167+
description: Always pull by default. Can be IfNotPresent
168+
- name: OCI_REGISTRY_IMAGE
169+
value: quay.io/devfile/oci-registry
170+
displayName: OCI registry index image
171+
description: OCI registry index docker image. Defaults to quay.io/devfile/devfile-index
172+
- name: OCI_REGISTRY_IMAGE_TAG
173+
value: next
174+
displayName: OCI registry version
175+
description: OCI registry version which defaults to next
176+
- name: OCI_REGISTRY_MEMORY_LIMIT
177+
value: 256Mi
178+
displayName: Memory Limit
179+
description: Maximum amount of memory the OCI registry container can use. Defaults 256Mi
180+
- name: OCI_REGISTRY_PULL_POLICY
181+
value: Always
182+
displayName: Devfile registry image pull policy
183+
description: Always pull by default. Can be IfNotPresent
184+
- name: REPLICAS
185+
value: "1"
186+
displayName: Devfile registry replicas
187+
description: The number of replicas for the hosted devfile registry service

.github/workflows/ci.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Check registry build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v2
16+
with:
17+
path: registry-repo
18+
- name: Setup Go environment
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.13
22+
23+
- name: Check if devfile registry build is working
24+
run: registry-repo/.ci/build.sh

0 commit comments

Comments
 (0)