diff --git a/Makefile b/Makefile index 49fc1319..54aa171e 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ build: make -C packages/system/kubeovn image make -C packages/system/dashboard image make -C packages/system/kamaji image + make -C packages/system/bucket image make -C packages/core/testing image make -C packages/core/installer image make manifests diff --git a/packages/apps/bucket/templates/dashboard-resourcemap.yaml b/packages/apps/bucket/templates/dashboard-resourcemap.yaml index 560d0d29..574af0cb 100644 --- a/packages/apps/bucket/templates/dashboard-resourcemap.yaml +++ b/packages/apps/bucket/templates/dashboard-resourcemap.yaml @@ -9,4 +9,12 @@ rules: - secrets resourceNames: - {{ .Release.Name }} + - {{ .Release.Name }}-credentials + verbs: ["get", "list", "watch"] +- apiGroups: + - networking.k8s.io + resources: + - ingresses + resourceNames: + - {{ .Release.Name }}-ui verbs: ["get", "list", "watch"] diff --git a/packages/apps/bucket/templates/helmrelease.yaml b/packages/apps/bucket/templates/helmrelease.yaml new file mode 100644 index 00000000..ac014e03 --- /dev/null +++ b/packages/apps/bucket/templates/helmrelease.yaml @@ -0,0 +1,18 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: {{ .Release.Name }}-system +spec: + chart: + spec: + chart: cozy-bucket + reconcileStrategy: Revision + sourceRef: + kind: HelmRepository + name: cozystack-system + namespace: cozy-system + version: '*' + interval: 1m0s + timeout: 5m0s + values: + bucketName: {{ .Release.Name }} diff --git a/packages/system/bucket/.helmignore b/packages/system/bucket/.helmignore new file mode 100644 index 00000000..988ec8c8 --- /dev/null +++ b/packages/system/bucket/.helmignore @@ -0,0 +1,2 @@ +hack +.gitkeep diff --git a/packages/system/bucket/Chart.yaml b/packages/system/bucket/Chart.yaml new file mode 100644 index 00000000..d520027f --- /dev/null +++ b/packages/system/bucket/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: cozy-bucket +version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process diff --git a/packages/system/bucket/Makefile b/packages/system/bucket/Makefile new file mode 100644 index 00000000..98f49ec6 --- /dev/null +++ b/packages/system/bucket/Makefile @@ -0,0 +1,25 @@ +S3MANAGER_TAG=v0.5.0 + +export NAME=s3manager-system + +include ../../../scripts/common-envs.mk +include ../../../scripts/package.mk + +update: + rm -rf charts + helm pull oci://ghcr.io/aenix-io/charts/etcd-operator --untar --untardir charts + +image: image-s3manager + +image-s3manager: + docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/s3manager \ + --provenance false \ + --tag $(REGISTRY)/s3manager:$(call settag,$(S3MANAGER_TAG)) \ + --cache-from type=registry,ref=$(REGISTRY)/s3manager:latest \ + --cache-to type=inline \ + --metadata-file images/s3manager.json \ + --push=$(PUSH) \ + --load=$(LOAD) + echo "$(REGISTRY)/s3manager:$(call settag,$(S3MANAGER_TAG))@$$(yq e '."containerimage.digest"' images/s3manager.json -o json -r)" \ + > images/s3manager.tag + rm -f images/s3manager.json diff --git a/packages/system/bucket/images/s3manager.tag b/packages/system/bucket/images/s3manager.tag new file mode 100644 index 00000000..d86bf0c8 --- /dev/null +++ b/packages/system/bucket/images/s3manager.tag @@ -0,0 +1 @@ +ghcr.io/aenix-io/cozystack/s3manager:latest@sha256:7a1a0864f823dc3343d79dffa44ab73f77f0e1b3642a0fe0fa29b280c3184a9b diff --git a/packages/system/bucket/images/s3manager/Dockerfile b/packages/system/bucket/images/s3manager/Dockerfile new file mode 100644 index 00000000..de59229a --- /dev/null +++ b/packages/system/bucket/images/s3manager/Dockerfile @@ -0,0 +1,20 @@ +# Source: https://github.com/cloudlena/s3manager/blob/main/Dockerfile + +FROM docker.io/library/golang:1 AS builder +WORKDIR /usr/src/app +RUN wget -O- https://github.com/cloudlena/s3manager/archive/9a7c8e446b422f8973b8c461990f39fdafee9c27.tar.gz | tar -xzf- --strip 1 +ADD cozystack.patch / +RUN git apply /cozystack.patch +RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager + +FROM docker.io/library/alpine:latest +WORKDIR /usr/src/app +RUN addgroup -S s3manager && adduser -S s3manager -G s3manager +RUN apk add --no-cache \ + ca-certificates \ + dumb-init +COPY --from=builder --chown=s3manager:s3manager /usr/src/app/bin/s3manager ./ +USER s3manager +EXPOSE 8080 +ENTRYPOINT [ "/usr/bin/dumb-init", "--" ] +CMD [ "/usr/src/app/s3manager" ] diff --git a/packages/system/bucket/images/s3manager/cozystack.patch b/packages/system/bucket/images/s3manager/cozystack.patch new file mode 100644 index 00000000..f631b144 --- /dev/null +++ b/packages/system/bucket/images/s3manager/cozystack.patch @@ -0,0 +1,26 @@ +diff --git a/web/template/bucket.html.tmpl b/web/template/bucket.html.tmpl +index e2f8d28..87add13 100644 +--- a/web/template/bucket.html.tmpl ++++ b/web/template/bucket.html.tmpl +@@ -13,7 +13,7 @@ + +