Skip to content

Commit ee38427

Browse files
committed
feat(imagebuilder): imagebuilder v3
0 parents  commit ee38427

21 files changed

Lines changed: 607 additions & 0 deletions

File tree

.drone/drone.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
kind: pipeline
2+
type: docker
3+
name: linux-amd64
4+
5+
platform:
6+
arch: amd64
7+
os: linux
8+
9+
steps:
10+
- name: test
11+
image: docker.io/drycc/go-dev
12+
pull: if-not-exists
13+
privileged: true
14+
commands:
15+
- make docker-build test
16+
environment:
17+
VERSION: ${DRONE_TAG:-latest}-linux-amd64
18+
DEV_REGISTRY: ${DEV_REGISTRY:-docker.io}
19+
DRYCC_REGISTRY: ${DRYCC_REGISTRY:-docker.io}
20+
when:
21+
event:
22+
- push
23+
- tag
24+
- pull_request
25+
volumes:
26+
- name: image_registries
27+
path: /etc/containers/registries.conf
28+
29+
- name: publish
30+
image: docker.io/drycc/go-dev
31+
pull: if-not-exists
32+
privileged: true
33+
commands:
34+
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
35+
- make docker-build docker-immutable-push
36+
environment:
37+
VERSION: ${DRONE_TAG:-latest}-linux-amd64
38+
DEV_REGISTRY:
39+
from_secret: dev_registry
40+
DRYCC_REGISTRY:
41+
from_secret: drycc_registry
42+
DOCKER_USERNAME:
43+
from_secret: docker_username
44+
DOCKER_PASSWORD:
45+
from_secret: docker_password
46+
when:
47+
event:
48+
- push
49+
- tag
50+
volumes:
51+
- name: image_registries
52+
path: /etc/containers/registries.conf
53+
54+
trigger:
55+
event:
56+
- push
57+
- tag
58+
- pull_request
59+
60+
volumes:
61+
- name: image_registries
62+
host:
63+
path: /etc/containers/registries.conf
64+
65+
---
66+
kind: pipeline
67+
type: docker
68+
name: linux-arm64
69+
70+
platform:
71+
arch: arm64
72+
os: linux
73+
74+
steps:
75+
- name: publish
76+
image: docker.io/drycc/go-dev
77+
pull: if-not-exists
78+
privileged: true
79+
commands:
80+
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
81+
- make docker-build docker-immutable-push
82+
environment:
83+
VERSION: ${DRONE_TAG:-latest}-linux-arm64
84+
DEV_REGISTRY:
85+
from_secret: dev_registry
86+
DRYCC_REGISTRY:
87+
from_secret: drycc_registry
88+
DOCKER_USERNAME:
89+
from_secret: docker_username
90+
DOCKER_PASSWORD:
91+
from_secret: docker_password
92+
volumes:
93+
- name: image_registries
94+
path: /etc/containers/registries.conf
95+
96+
trigger:
97+
event:
98+
- push
99+
- tag
100+
101+
volumes:
102+
- name: image_registries
103+
host:
104+
path: /etc/containers/registries.conf
105+
106+
---
107+
kind: pipeline
108+
type: docker
109+
name: manifest
110+
111+
steps:
112+
- name: generate manifest
113+
image: docker.io/library/alpine
114+
pull: if-not-exists
115+
commands:
116+
- sed -i "s/docker.io/$${DRYCC_REGISTRY}/g" .drone/manifest.tmpl
117+
environment:
118+
DRYCC_REGISTRY:
119+
from_secret: drycc_registry
120+
121+
- name: publish
122+
image: plugins/manifest
123+
settings:
124+
spec: .drone/manifest.tmpl
125+
username:
126+
from_secret: docker_username
127+
password:
128+
from_secret: docker_password
129+
environment:
130+
DEV_REGISTRY:
131+
from_secret: dev_registry
132+
DRYCC_REGISTRY:
133+
from_secret: drycc_registry
134+
135+
trigger:
136+
event:
137+
- push
138+
- tag
139+
140+
depends_on:
141+
- linux-amd64
142+
- linux-arm64
143+
144+
---
145+
kind: pipeline
146+
type: docker
147+
name: chart
148+
149+
steps:
150+
- name: generate chart
151+
image: docker.io/drycc/python-dev
152+
commands:
153+
- IMAGE_TAG=$([ ! -z $DRONE_TAG ] && echo ${DRONE_TAG:1} || echo \"canary\")
154+
- sed -i "s/image_tag:\ \"canary\"/image_tag:\ $IMAGE_TAG/g" charts/buildparker/values.yaml
155+
- helm package charts/buildparker --version ${DRONE_TAG:-v1.0.0}
156+
- curl -u $CHARTMUSEUM_USERNAME:$CHARTMUSEUM_PASSWORD -F chart=@buildparker-${DRONE_TAG:-v1.0.0}.tgz "$CHARTMUSEUM_API/api/$([ -z $DRONE_TAG ] && echo testing |echo stable)/charts"
157+
environment:
158+
CHARTMUSEUM_USERNAME:
159+
from_secret: chartmuseum_username
160+
CHARTMUSEUM_PASSWORD:
161+
from_secret: chartmuseum_password
162+
CHARTMUSEUM_API:
163+
from_secret: chartmuseum_api
164+
165+
trigger:
166+
event:
167+
- push
168+
- tag

.drone/manifest.tmpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
image: docker.io/drycc/buildparker:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}canary{{/if}}
3+
{{#if build.tags}}
4+
tags:
5+
{{#each build.tags}}
6+
- {{this}}
7+
{{/each}}
8+
{{/if}}
9+
manifests:
10+
-
11+
image: docker.io/drycc/buildparker:{{#if build.tag}}{{build.tag}}-{{else}}latest-{{/if}}linux-amd64
12+
platform:
13+
architecture: amd64
14+
os: linux
15+
-
16+
image: docker.io/drycc/buildparker:{{#if build.tag}}{{build.tag}}-{{else}}latest-{{/if}}linux-arm64
17+
platform:
18+
architecture: arm64
19+
os: linux

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Contributing to Drycc
2+
3+
This project is part of Drycc. You can find the latest contribution
4+
guidelines [in our documentation](https://drycc.com/docs/workflow/contributing/overview/).

DCO

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Developer Certificate of Origin
2+
Version 1.1
3+
4+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5+
660 York Street, Suite 102,
6+
San Francisco, CA 94110 USA
7+
8+
Everyone is permitted to copy and distribute verbatim copies of this
9+
license document, but changing it is not allowed.
10+
11+
12+
Developer's Certificate of Origin 1.1
13+
14+
By making a contribution to this project, I certify that:
15+
16+
(a) The contribution was created in whole or in part by me and I
17+
have the right to submit it under the open source license
18+
indicated in the file; or
19+
20+
(b) The contribution is based upon previous work that, to the best
21+
of my knowledge, is covered under an appropriate open source
22+
license and I have the right under that license to submit that
23+
work with modifications, whether created in whole or in part
24+
by me, under the same open source license (unless I am
25+
permitted to submit under a different license), as indicated
26+
in the file; or
27+
28+
(c) The contribution was provided directly to me by some other
29+
person who certified (a), (b) or (c) and I have not modified
30+
it.
31+
32+
(d) I understand and agree that this project and the contribution
33+
are public and that a record of the contribution (including all
34+
personal information I submit with it, including my sign-off) is
35+
maintained indefinitely and may be redistributed consistent with
36+
this project or the open source license(s) involved.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Drycc team. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MAINTAINERS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Drycc Maintainers
2+
3+
This project is part of Drycc. The official maintainers documentation is
4+
located.

Makefile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
SHORT_NAME ?= imagebuilder
2+
DRYCC_REGISTRY ?= ${DEV_REGISTRY}
3+
PLATFORM ?= linux/amd64,linux/arm64
4+
5+
export GO15VENDOREXPERIMENT=1
6+
7+
# Note that Minio currently uses CGO.
8+
9+
LDFLAGS := "-s -X main.version=${VERSION}"
10+
IMAGE_PREFIX ?= drycc
11+
BINDIR := ./rootfs/bin
12+
13+
include versioning.mk
14+
15+
SHELL_SCRIPTS = $(wildcard _scripts/*.sh) \
16+
rootfs/usr/local/bin/* \
17+
rootfs/pack/*
18+
19+
# The following variables describe the containerized development environment
20+
# and other build options
21+
DEV_ENV_IMAGE := ${DEV_REGISTRY}/drycc/go-dev
22+
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
23+
DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
24+
DEV_ENV_CMD_INT := docker run -it --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
25+
26+
all: build docker-build docker-push
27+
28+
bootstrap:
29+
@echo Nothing to do.
30+
31+
build:
32+
@echo Nothing to do.
33+
34+
docker-build:
35+
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} -f rootfs/Dockerfile rootfs
36+
docker tag ${IMAGE} ${MUTABLE_IMAGE}
37+
38+
docker-buildx:
39+
docker buildx build --platform ${PLATFORM} ${DOCKER_BUILD_FLAGS} -t ${IMAGE} -f rootfs/Dockerfile rootfs --push
40+
41+
deploy: docker-build docker-push
42+
43+
kube-pod: kube-service
44+
kubectl create -f ${POD}
45+
46+
kube-secrets:
47+
- kubectl create -f ${SEC}
48+
49+
secrets:
50+
perl -pi -e "s|access-key-id: .+|access-key-id: ${key}|g" ${SEC}
51+
perl -pi -e "s|access-secret-key: .+|access-secret-key: ${secret}|g" ${SEC}
52+
echo ${key} ${secret}
53+
54+
kube-service: kube-secrets
55+
- kubectl create -f ${SVC}
56+
57+
kube-clean:
58+
- kubectl delete rc drycc-${SHORT_NAME}-rc
59+
60+
test: test-style test-unit test-functional
61+
62+
test-style:
63+
${DEV_ENV_CMD} shellcheck $(SHELL_SCRIPTS)
64+
65+
test-unit:
66+
docker run --entrypoint /usr/bin/env ${IMAGE} python3 -m unittest procfile
67+
68+
test-functional:
69+
@echo "Implement functional tests in _tests directory"
70+
71+
.PHONY: all bootstrap build docker-build docker-push deploy kube-pod kube-secrets \
72+
secrets kube-service kube-clean test

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Drycc imagebuilder v3
2+
[![Build Status](https://drone.drycc.cc/api/badges/drycc/imagebuilder/status.svg)](https://drone.drycc.cc/drycc/imagebuilder)
3+
4+
Drycc (pronounced DAY-iss) Workflow is an open source Platform as a Service (PaaS) that adds a developer-friendly layer to any [Kubernetes](http://kubernetes.io) cluster, making it easy to deploy and manage applications on your own servers.
5+
6+
For more information about the Drycc Workflow, please visit the main project page at https://github.com/drycc/workflow.
7+
8+
We welcome your input! If you have feedback, please [submit an issue][issues]. If you'd like to participate in development, please read the "Development" section below and [submit a pull request][prs].
9+
10+
# About
11+
12+
The imagebuilder downloads a git archive ([gzip](http://www.gzip.org/)ped [tar](https://www.gnu.org/software/tar/)ball) from a specified [S3 API compatible server][s3-api], compiles a [slug](https://devcenter.heroku.com/articles/slug-compiler) and uploads it to a specified S3 API compatible server.
13+
14+
This component is usually launched by the [Drycc Builder](https://github.com/drycc/builder) and used inside the Drycc [PaaS](https://en.wikipedia.org/wiki/Platform_as_a_service), but it is flexible enough to be used as a pod inside any Kubernetes cluster.
15+
16+
Please see https://github.com/drycc/builder/blob/master/README.md for a more detailed description of how `imagebuilder` interacts with `builder`.
17+
18+
# Development
19+
20+
The Drycc project welcomes contributions from all developers. The high level process for development matches many other open source projects. See below for an outline.
21+
22+
* Fork this repository
23+
* Make your changes
24+
* [Submit a pull request][prs] (PR) to this repository with your changes, and unit tests whenever possible.
25+
* If your PR fixes any [issues][issues], make sure you write Fixes #1234 in your PR description (where #1234 is the number of the issue you're closing)
26+
* The Drycc core contributors will review your code. After each of them sign off on your code, they'll label your PR with LGTM1 and LGTM2 (respectively). Once that happens, the contributors will merge it
27+
28+
[issues]: https://github.com/drycc/imagebuilder/issues
29+
[prs]: https://github.com/drycc/imagebuilder/pulls
30+
[s3-api]: http://docs.aws.amazon.com/AmazonS3/latest/API/APIRest.html

_docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# drycc-imagebuilder on Kubernetes

_docs/users.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Version": "0.0.1",
3+
"Users": {
4+
"admin": {
5+
"name": "admin",
6+
"accessKeyId": "admin",
7+
"secretAccessKey": "pdG8Rpw0h8QtxybHsMHlkJtzJzZ2sC7b2cFBEgn+"
8+
},
9+
"user": {
10+
"name": "user",
11+
"accessKeyId": "8TZRY2JRWMPT6UMXR6I5",
12+
"secretAccessKey": "gbstrOvotMMcg2sMfGUhA5a6Et/EI5ALtIHsobYk"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)