Skip to content

Commit 3c4ea0e

Browse files
committed
Move single main package to root of the repository
The binary is called pyrra
1 parent 61c6dcd commit 3c4ea0e

12 files changed

+38
-41
lines changed

.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.github/
2+
config/
3+
cue.mod/
4+
docs/
5+
examples/
6+
ui/build/
7+
ui/node_modules/

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ bin
2222
*.swo
2323
*~
2424

25-
/cmd/api/ui/
25+
/pyrra

cmd/api/Dockerfile renamed to Dockerfile

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ FROM golang:1.16 as builder
1616

1717
WORKDIR /workspace
1818

19-
COPY cmd/api/ cmd/api/
2019
COPY kubernetes/ kubernetes/
2120
COPY openapi/ openapi/
2221
COPY slo/ slo/
23-
COPY go.mod go.mod
24-
COPY go.sum go.sum
22+
COPY *.go ./
23+
COPY go.mod ./
24+
COPY go.sum ./
2525
COPY Makefile Makefile
26-
COPY --from=uibuilder /workspace/ui/build /workspace/cmd/api/ui/build
26+
COPY --from=uibuilder /workspace/ui/build /workspace/ui/build
2727
# cache deps before building and copying source so that we don't need to re-download as much
2828
# and so that source changes don't invalidate our downloaded layer
2929
RUN go mod download
30-
RUN make api
30+
RUN make pyrra
3131

3232
FROM alpine:3.14
3333
WORKDIR /
34-
COPY --from=builder /workspace/bin/api /usr/bin/api
34+
COPY --from=builder /workspace/pyrra /usr/bin/pyrra
3535

36-
ENTRYPOINT ["/usr/bin/api"]
36+
ENTRYPOINT ["/usr/bin/pyrra"]

Makefile

+17-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Image URL to use all building/pushing image targets
2-
IMG_API ?= api:latest
2+
IMG ?= ghcr.io/pyrra-dev/pyrra:main
33

44
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
55
CRD_OPTIONS ?= "crd:trivialVersions=true"
@@ -16,20 +16,23 @@ OPENAPI ?= docker run --rm \
1616
-v ${PWD}:${PWD} \
1717
openapitools/openapi-generator-cli:v5.1.1
1818

19-
all: ui build lint
19+
all: ui/build build lint
20+
21+
.PHONY: install
22+
install: ui/node_modules
2023

2124
clean:
22-
rm -rf ui/build ui/node_modules cmd/api/ui/build
25+
rm -rf ui/build ui/node_modules
2326

2427
# Run tests
2528
test: generate fmt vet manifests
2629
go test -race ./... -coverprofile cover.out
2730

28-
build: api
31+
build: pyrra
2932

3033
# Build api binary
31-
api: fmt vet
32-
CGO_ENABLED=0 go build -v -ldflags '-w -extldflags '-static'' -o bin/api ./cmd/api
34+
pyrra: fmt vet
35+
CGO_ENABLED=0 go build -v -ldflags '-w -extldflags '-static'' -o pyrra
3336

3437
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
3538
deploy: manifests config/api.yaml config/kubernetes.yaml
@@ -41,13 +44,15 @@ deploy: manifests config/api.yaml config/kubernetes.yaml
4144
manifests: controller-gen
4245
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=pyrra-kubernetes webhook paths="./..." output:crd:artifacts:config=config/crd/bases
4346

47+
config: config/api.yaml config/kubernetes.yaml
48+
4449
config/api.yaml: config/api.cue
4550
cue fmt -s ./config/
46-
cue cmd --inject imageAPI=${IMG_API} "api.yaml" ./config
51+
cue cmd --inject image=${IMG} "api.yaml" ./config
4752

4853
config/kubernetes.yaml: config/kubernetes.cue
4954
cue fmt -s ./config/
50-
cue cmd --inject imageKubernetes=${IMG_KUBERNETES} "kubernetes.yaml" ./config
55+
cue cmd --inject image=${IMG} "kubernetes.yaml" ./config
5156

5257
# Run code linters
5358
lint: fmt vet
@@ -64,17 +69,11 @@ vet:
6469
generate: controller-gen manifests
6570
$(CONTROLLER_GEN) object:headerFile="kubernetes/hack/boilerplate.go.txt" paths="./..."
6671

67-
# Build the docker image
68-
docker-build: docker-build-api
69-
70-
docker-build-api:
71-
docker build . -t ${IMG_API} -f ./cmd/api/Dockerfile
72-
73-
# Push the docker image
74-
docker-push: docker-push-api
72+
docker-build:
73+
docker build . -t ${IMG}
7574

76-
docker-push-api:
77-
docker push ${IMG_API}
75+
docker-push:
76+
docker push ${IMG}
7877

7978
# find or download controller-gen
8079
# download controller-gen if necessary
@@ -114,19 +113,8 @@ ui/src/client: api.yaml
114113
-rm -f $@
115114
$(OPENAPI) generate -i ${PWD}/api.yaml -g typescript-fetch -o ${PWD}/ui/src/client
116115

117-
.PHONY: install
118-
install: ui/node_modules
119-
120116
ui/node_modules:
121117
cd ui && npm install
122118

123-
.PHONY: ui
124-
ui: cmd/api/ui/build
125-
126119
ui/build:
127120
cd ui && npm run build
128-
129-
cmd/api/ui/build: ui/build
130-
rm -rf ./cmd/api/ui
131-
mkdir -p ./cmd/api/ui/
132-
cp -r ./ui/build ./cmd/api/ui/

config/api.cue

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ api: {
99
_name: "pyrra-api"
1010
_namespace: "monitoring"
1111
_replicas: 1
12-
_image: "api:latest" | string @tag(imageAPI)
12+
_image: "pyrra:latest" | string @tag(image)
1313
_ports: http: 9099
1414

1515
service: corev1.#Service & {
@@ -41,6 +41,7 @@ api: {
4141
metadata: labels: "app.kubernetes.io/name": _name
4242
spec: containers: [{
4343
args: [
44+
"api",
4445
"--prometheus.url=http://prometheus-k8s.monitoring.svc.cluster.local:9090",
4546
"--api.url=http://\( kubernetes._name ).\(kubernetes._namespace).svc.cluster.local:\(kubernetes._ports.api)",
4647
]

config/api.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ spec:
2929
spec:
3030
containers:
3131
- args:
32+
- api
3233
- --prometheus.url=http://prometheus-k8s.monitoring.svc.cluster.local:9090
3334
- --api.url=http://pyrra-kubernetes.monitoring.svc.cluster.local:9444
34-
image: api:latest
35+
image: ghcr.io/pyrra-dev/pyrra:main
3536
name: pyrra-api
3637
ports:
3738
- name: http

config/kubernetes.cue

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ kubernetes: {
1010
_name: "pyrra-kubernetes"
1111
_namespace: "monitoring"
1212
_replicas: 1
13-
_image: "controller:latest" | string @tag(imageKubernetes)
13+
_image: "pyrra:latest" | string @tag(image)
1414
_ports: {
1515
internal: 9443
1616
api: 9444

config/kubernetes.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
containers:
3434
- command:
3535
- /kubernetes
36-
image: kubernetes:latest
36+
image: ghcr.io/pyrra-dev/pyrra:main
3737
name: pyrra-kubernetes
3838
resources:
3939
limits:
File renamed without changes.
File renamed without changes.

cmd/api/main.go renamed to main.go

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)