Skip to content

Commit b50cd88

Browse files
committed
Initial commit
0 parents  commit b50cd88

File tree

11 files changed

+746
-0
lines changed

11 files changed

+746
-0
lines changed

.conform.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
policies:
2+
- type: commit
3+
spec:
4+
headerLength: 89
5+
dco: true
6+
gpg: false
7+
imperative: true
8+
maximumOfOneCommit: true
9+
requireCommitBody: true
10+
conventional:
11+
types:
12+
- chore
13+
- docs
14+
- perf
15+
- refactor
16+
- style
17+
- test
18+
scopes:
19+
- '*'
20+
- type: license
21+
spec:
22+
skipPaths:
23+
- .git/
24+
includeSuffixes:
25+
- .go
26+
header: |
27+
// This Source Code Form is subject to the terms of the Mozilla Public
28+
// License, v. 2.0. If a copy of the MPL was not distributed with this
29+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*
2+
!api
3+
!config
4+
!controllers
5+
!hack
6+
!internal
7+
!pkg
8+
!go.mod
9+
!go.sum
10+
!main.go

.drone.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
---
2+
kind: secret
3+
name: kubeconfig
4+
5+
get:
6+
path: buildx
7+
name: kubeconfig
8+
9+
---
10+
kind: pipeline
11+
name: default
12+
13+
services:
14+
- name: docker
15+
image: docker:19.03-dind
16+
entrypoint:
17+
- dockerd
18+
command:
19+
- --dns=8.8.8.8
20+
- --dns=8.8.4.4
21+
- --log-level=error
22+
privileged: true
23+
volumes:
24+
- name: docker-socket
25+
path: /var/run
26+
27+
steps:
28+
- name: setup-ci
29+
image: autonomy/build-container:latest
30+
commands:
31+
- git fetch --tags
32+
- apk add coreutils
33+
- echo -e "$BUILDX_KUBECONFIG" > /root/.kube/config
34+
- docker buildx create --driver kubernetes --driver-opt replicas=2 --driver-opt namespace=ci --driver-opt image=moby/buildkit:v0.6.2 --name ci --buildkitd-flags="--allow-insecure-entitlement security.insecure" --use
35+
- docker buildx inspect --bootstrap
36+
environment:
37+
BUILDX_KUBECONFIG:
38+
from_secret: kubeconfig
39+
privileged: true
40+
volumes:
41+
- name: docker-socket
42+
path: /var/run
43+
- name: docker
44+
path: /root/.docker/buildx
45+
- name: kube
46+
path: /root/.kube
47+
48+
- name: build-pull-request
49+
image: autonomy/build-container:latest
50+
pull: always
51+
commands:
52+
- make
53+
when:
54+
event:
55+
include:
56+
- pull_request
57+
volumes:
58+
- name: docker-socket
59+
path: /var/run
60+
- name: docker
61+
path: /root/.docker/buildx
62+
- name: kube
63+
path: /root/.kube
64+
65+
- name: build-and-publish
66+
image: autonomy/build-container:latest
67+
pull: always
68+
environment:
69+
DOCKER_USERNAME:
70+
from_secret: docker_username
71+
DOCKER_PASSWORD:
72+
from_secret: docker_password
73+
commands:
74+
- docker login --username "$${DOCKER_USERNAME}" --password "$${DOCKER_PASSWORD}"
75+
- make PUSH=true
76+
when:
77+
event:
78+
exclude:
79+
- pull_request
80+
volumes:
81+
- name: docker-socket
82+
path: /var/run
83+
- name: docker
84+
path: /root/.docker/buildx
85+
- name: kube
86+
path: /root/.kube
87+
88+
- name: build-release
89+
image: autonomy/build-container:latest
90+
pull: always
91+
commands:
92+
- make release
93+
when:
94+
event:
95+
- tag
96+
volumes:
97+
- name: docker-socket
98+
path: /var/run
99+
- name: docker
100+
path: /root/.docker/buildx
101+
- name: kube
102+
path: /root/.kube
103+
104+
- name: release
105+
image: plugins/github-release
106+
settings:
107+
api_key:
108+
from_secret: github_token
109+
checksum:
110+
- sha256
111+
- sha512
112+
draft: true
113+
files:
114+
- _out/*
115+
when:
116+
event:
117+
- tag
118+
119+
volumes:
120+
- name: docker-socket
121+
temp: {}
122+
- name: docker
123+
temp: {}
124+
- name: kube
125+
temp: {}
126+
---
127+
kind: pipeline
128+
name: notify
129+
130+
clone:
131+
disable: true
132+
133+
steps:
134+
- name: slack
135+
image: plugins/slack
136+
settings:
137+
webhook:
138+
from_secret: slack_webhook
139+
channel: proj-talos-maintainers
140+
when:
141+
status:
142+
- success
143+
- failure
144+
145+
trigger:
146+
status:
147+
- success
148+
- failure
149+
150+
depends_on:
151+
- default

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_out

Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# syntax = docker/dockerfile-upstream:1.1.4-experimental
2+
3+
FROM golang:1.13 AS build
4+
ENV GO111MODULE on
5+
ENV GOPROXY https://proxy.golang.org
6+
ENV CGO_ENABLED 0
7+
WORKDIR /tmp
8+
RUN go get sigs.k8s.io/controller-tools/cmd/[email protected]
9+
WORKDIR /src
10+
COPY ./go.mod ./
11+
COPY ./go.sum ./
12+
RUN go mod download
13+
RUN go mod verify
14+
COPY ./ ./
15+
RUN go list -mod=readonly all >/dev/null
16+
RUN ! go mod tidy -v 2>&1 | grep .
17+
18+
FROM build AS manifests-build
19+
ARG NAME
20+
RUN controller-gen rbac:roleName=${NAME}-role crd paths="./..." output:rbac:artifacts:config=config/rbac output:crd:artifacts:config=config/crd/bases
21+
FROM scratch AS manifests
22+
COPY --from=manifests-build /src/config/crd /config/crd
23+
COPY --from=manifests-build /src/config/rbac /config/rbac
24+
25+
FROM build AS generate-build
26+
RUN controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..."
27+
FROM scratch AS generate
28+
COPY --from=generate-build /src/api /api
29+
30+
FROM k8s.gcr.io/hyperkube:v1.17.0 AS release-build
31+
RUN apt update -y \
32+
&& apt install -y curl \
33+
&& curl -LO https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.4.0/kustomize_v3.4.0_linux_amd64.tar.gz \
34+
&& tar -xf kustomize_v3.4.0_linux_amd64.tar.gz -C /usr/local/bin \
35+
&& rm kustomize_v3.4.0_linux_amd64.tar.gz
36+
COPY ./config ./config
37+
ARG REGISTRY_AND_USERNAME
38+
ARG NAME
39+
ARG TAG
40+
RUN cd config/manager \
41+
&& kustomize edit set image controller=${REGISTRY_AND_USERNAME}/${NAME}:${TAG} \
42+
&& cd - \
43+
&& kubectl kustomize config >/release.yaml
44+
FROM scratch AS release
45+
COPY --from=release-build /release.yaml /release.yaml
46+
47+
FROM build AS binary
48+
RUN --mount=type=cache,target=/root/.cache/go-build GOOS=linux go build -ldflags "-s -w" -o /manager
49+
RUN chmod +x /manager
50+
51+
FROM scratch AS container
52+
COPY --from=docker.io/autonomy/ca-certificates:v0.1.0 / /
53+
COPY --from=docker.io/autonomy/fhs:v0.1.0 / /
54+
COPY --from=binary /manager /manager
55+
ENTRYPOINT [ "/manager" ]

0 commit comments

Comments
 (0)