Merge pull request #18 from giolekva/bazel
Bazel: build and push face-detection image
#7
diff --git a/apps/container-registry/install.yaml b/apps/container-registry/install.yaml
index bec3383..37327df 100644
--- a/apps/container-registry/install.yaml
+++ b/apps/container-registry/install.yaml
@@ -42,11 +42,12 @@
number: 5000
---
apiVersion: apps/v1
-kind: Deployment
+kind: StatefulSet
metadata:
name: registry
namespace: container-registry
spec:
+ serviceName: registry
selector:
matchLabels:
app: registry
@@ -60,6 +61,9 @@
- name: registry
image: registry:2
imagePullPolicy: IfNotPresent
+ volumeMounts:
+ - name: registry-dir
+ mountPath: /var/lib/registry
env:
# - name: REGISTRY_REDIRECT_DISABLE
# value: "true"
@@ -75,3 +79,18 @@
value: 0.0.0.0:5000
ports:
- containerPort: 5000
+ volumes:
+ - name: registry-dir
+ persistentVolumeClaim:
+ claimName: registry-dir
+ volumeClaimTemplates:
+ - metadata:
+ name: registry-dir
+ annotations:
+ volume.alpha.kubernetes.io/storage-class: local-path
+ spec:
+ accessModes:
+ - "ReadWriteOnce"
+ resources:
+ requests:
+ storage: 1Gi
diff --git a/apps/face-detection/chart/face-detection.tar.gz b/apps/face-detection/chart/face-detection.tar.gz
deleted file mode 100644
index 8e5f353..0000000
--- a/apps/face-detection/chart/face-detection.tar.gz
+++ /dev/null
Binary files differ
diff --git a/apps/face-detection/chart/values.yaml b/apps/face-detection/chart/values.yaml
deleted file mode 100644
index 987d303..0000000
--- a/apps/face-detection/chart/values.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-replicas: 1
-image:
- name: giolekva/minio-importer
- tag: latest
- pullPolicy: Always
-servicePort: 80
-containerPort: 1234
-pcloudApiAddress: http://api.pcloud.svc:1111/graphql
\ No newline at end of file
diff --git a/apps/face_detection/BUILD b/apps/face_detection/BUILD
new file mode 100644
index 0000000..d1ed253
--- /dev/null
+++ b/apps/face_detection/BUILD
@@ -0,0 +1,22 @@
+load("@rules_pkg//:pkg.bzl", "pkg_tar")
+
+# TODO(lekva): figure out how to build py_binary with pip dependencies and
+# migrate off of shell script running docker build
+sh_binary(
+ name = "push_to_dev",
+ srcs = ["push_to_dev.sh"],
+ data = glob(["*.py"]) + [
+ "Dockerfile",
+ "haarcascade_frontalface_default.xml",
+ ],
+ deps = [
+ "@bazel_tools//tools/bash/runfiles",
+ ],
+)
+
+pkg_tar(
+ name = "chart",
+ srcs = glob(["chart/**"]),
+ extension = "tar.gz",
+ strip_prefix = "./chart",
+)
diff --git a/apps/face-detection/Dockerfile b/apps/face_detection/Dockerfile
similarity index 100%
rename from apps/face-detection/Dockerfile
rename to apps/face_detection/Dockerfile
diff --git a/apps/face-detection/chart/Chart.yaml b/apps/face_detection/chart/Chart.yaml
similarity index 100%
rename from apps/face-detection/chart/Chart.yaml
rename to apps/face_detection/chart/Chart.yaml
diff --git a/apps/face-detection/chart/README.md b/apps/face_detection/chart/README.md
similarity index 100%
rename from apps/face-detection/chart/README.md
rename to apps/face_detection/chart/README.md
diff --git a/apps/face-detection/chart/templates/pcloud/Actions.yaml b/apps/face_detection/chart/templates/pcloud/Actions.yaml
similarity index 84%
rename from apps/face-detection/chart/templates/pcloud/Actions.yaml
rename to apps/face_detection/chart/templates/pcloud/Actions.yaml
index 32b2a99..94dbf46 100644
--- a/apps/face-detection/chart/templates/pcloud/Actions.yaml
+++ b/apps/face_detection/chart/templates/pcloud/Actions.yaml
@@ -8,7 +8,7 @@
spec:
containers:
- name: detect-faces
- image: giolekva/face-detector:latest
+ image: {{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: Always
command: ["python3", "main.py"]
args: [{-{ .PCloudApiAddr }-}, {-{ .ObjectStoreAddr }-}, {-{ .Id }-}]
diff --git a/apps/face-detection/chart/templates/pcloud/Schema.yaml b/apps/face_detection/chart/templates/pcloud/Schema.yaml
similarity index 100%
rename from apps/face-detection/chart/templates/pcloud/Schema.yaml
rename to apps/face_detection/chart/templates/pcloud/Schema.yaml
diff --git a/apps/face-detection/chart/templates/pcloud/Triggers.yaml b/apps/face_detection/chart/templates/pcloud/Triggers.yaml
similarity index 100%
rename from apps/face-detection/chart/templates/pcloud/Triggers.yaml
rename to apps/face_detection/chart/templates/pcloud/Triggers.yaml
diff --git a/apps/face_detection/chart/values.yaml b/apps/face_detection/chart/values.yaml
new file mode 100644
index 0000000..d722483
--- /dev/null
+++ b/apps/face_detection/chart/values.yaml
@@ -0,0 +1,4 @@
+image:
+ name: localhost:30500/giolekva/face-detector
+ tag: latest
+ pullPolicy: Always
diff --git a/apps/face-detection/deploy.yaml b/apps/face_detection/deploy.yaml
similarity index 100%
rename from apps/face-detection/deploy.yaml
rename to apps/face_detection/deploy.yaml
diff --git a/apps/face-detection/haar.py b/apps/face_detection/haar.py
similarity index 100%
rename from apps/face-detection/haar.py
rename to apps/face_detection/haar.py
diff --git a/apps/face-detection/haarcascade_frontalface_default.xml b/apps/face_detection/haarcascade_frontalface_default.xml
similarity index 100%
rename from apps/face-detection/haarcascade_frontalface_default.xml
rename to apps/face_detection/haarcascade_frontalface_default.xml
diff --git a/apps/face-detection/main.py b/apps/face_detection/main.py
similarity index 97%
rename from apps/face-detection/main.py
rename to apps/face_detection/main.py
index 94b2d96..1d92491 100644
--- a/apps/face-detection/main.py
+++ b/apps/face_detection/main.py
@@ -26,7 +26,7 @@
def upload_face_segments(gql_endpoint, id, faces):
segments = [format_img_segment(id, f) for f in faces]
- data = {"query": "mutation {{ addImageSegment(input: [{segments}]) {{ imagesegment {{ id }} }} }}".format(
+ data = {"query": "mutation {{ addImageSegment(input: [{segments}]) {{ imageSegment {{ id }} }} }}".format(
segments=", ".join(segments))}
# encoded_data = urllib.parse.urlencode(data).encode('UTF-8')
req = urllib.request.Request(gql_endpoint, method="POST")
diff --git a/apps/face-detection/mtcnn.py b/apps/face_detection/mtcnn.py
similarity index 100%
rename from apps/face-detection/mtcnn.py
rename to apps/face_detection/mtcnn.py
diff --git a/apps/face_detection/push_to_dev.sh b/apps/face_detection/push_to_dev.sh
new file mode 100755
index 0000000..48342f9
--- /dev/null
+++ b/apps/face_detection/push_to_dev.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# --- begin runfiles.bash initialization ---
+# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
+set -euo pipefail
+if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ if [[ -f "$0.runfiles_manifest" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
+ elif [[ -f "$0.runfiles/MANIFEST" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
+ elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+DOCKERFILE="$(rlocation __main__/apps/face_detection/Dockerfile)"
+IMAGE="localhost:30500/giolekva/face-detector"
+
+docker build \
+ --tag=$IMAGE \
+ --file=$DOCKERFILE \
+ "$(dirname "$DOCKERFILE")"
+
+docker push $IMAGE
diff --git a/apps/minio/chart/minio.tar.gz b/apps/minio/chart/minio.tar.gz
deleted file mode 100644
index 19633bd..0000000
--- a/apps/minio/chart/minio.tar.gz
+++ /dev/null
Binary files differ
diff --git a/apps/minio/importer/chart/minio-importer.tar.gz b/apps/minio/importer/chart/minio-importer.tar.gz
deleted file mode 100644
index 50c978d..0000000
--- a/apps/minio/importer/chart/minio-importer.tar.gz
+++ /dev/null
Binary files differ
diff --git a/apps/photos-ui/chart/photos-ui.tar.gz b/apps/photos-ui/chart/photos-ui.tar.gz
deleted file mode 100644
index 15a0a03..0000000
--- a/apps/photos-ui/chart/photos-ui.tar.gz
+++ /dev/null
Binary files differ
diff --git a/apps/rpuppy/Dockerfile b/apps/rpuppy/Dockerfile
deleted file mode 100644
index 8dd6a7f..0000000
--- a/apps/rpuppy/Dockerfile
+++ /dev/null
@@ -1,22 +0,0 @@
-FROM golang:1-alpine AS build
-
-RUN apk update && apk upgrade && \
- apk add --no-cache bash git openssh
-
-WORKDIR /app
-RUN go get github.com/itaysk/regogo
-COPY main.go /app/main.go
-
-ENV CGO_ENABLED 0
-ENV GO111MODULE off
-RUN go build -o rpuppy -trimpath -ldflags="-s -w" main.go
-
-FROM alpine:latest
-WORKDIR /
-COPY --from=build /app/rpuppy /usr/bin/rpuppy
-
-ENV PORT 80
-EXPOSE ${PORT}
-CMD rpuppy --port=${PORT}
-
-
diff --git a/apps/rpuppy/chart/rpuppy.tar.gz b/apps/rpuppy/chart/rpuppy.tar.gz
deleted file mode 100644
index aac0497..0000000
--- a/apps/rpuppy/chart/rpuppy.tar.gz
+++ /dev/null
Binary files differ