diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 08d068f..c40e717 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -25,6 +25,8 @@ version: 1 env: - REGISTRY={{ if index .Env "REGISTRY" }}{{ .Env.REGISTRY }}{{ else }}ghcr.io/buoyantio{{ end }} - IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}faces{{ end }} + - EXTERNAL_BASE={{ if index .Env "EXTERNAL_BASE" }}{{ .Env.EXTERNAL_BASE }}{{ else }}ghcr.io/buoyantio/demo-external-base:0.3.0{{ end }} + - BEL_EXTERNAL_BASE={{ if index .Env "BEL_EXTERNAL_BASE" }}{{ .Env.BEL_EXTERNAL_BASE }}{{ else }}ghcr.io/buoyantio/demo-bel-external-base:0.3.0{{ end }} before: hooks: @@ -121,6 +123,7 @@ dockers: - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-external-workload:latest-arm64" build_flag_templates: - "--platform=linux/arm64" + - "--build-arg=EXTERNAL_BASE={{ .Env.EXTERNAL_BASE }}" - use: buildx goos: linux goarch: amd64 @@ -132,6 +135,31 @@ dockers: - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-external-workload:latest-amd64" build_flag_templates: - "--platform=linux/amd64" + - "--build-arg=EXTERNAL_BASE={{ .Env.EXTERNAL_BASE }}" + - use: buildx + goos: linux + goarch: arm64 + dockerfile: Dockerfiles/Dockerfile.bel-external-workload + ids: + - generic + image_templates: + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-external-workload:{{ .Version }}-arm64" + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-external-workload:latest-arm64" + build_flag_templates: + - "--platform=linux/arm64" + - "--build-arg=EXTERNAL_BASE={{ .Env.BEL_EXTERNAL_BASE }}" + - use: buildx + goos: linux + goarch: amd64 + dockerfile: Dockerfiles/Dockerfile.bel-external-workload + ids: + - generic + image_templates: + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-external-workload:{{ .Version }}-amd64" + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-external-workload:latest-amd64" + build_flag_templates: + - "--platform=linux/amd64" + - "--build-arg=EXTERNAL_BASE={{ .Env.BEL_EXTERNAL_BASE }}" # For the Pi, we only build an external-workload image for arm64. The Pi itself # is arm64, so there's no point in building for amd64, and we're not going to try @@ -152,6 +180,24 @@ dockers: - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-pi-workload:latest" build_flag_templates: - "--platform=linux/arm64" + - "--build-arg=EXTERNAL_BASE={{ .Env.EXTERNAL_BASE }}" + - use: buildx + goos: linux + goarch: arm64 + # Not a typo! We really do use the same Dockerfile as the generic external + # workload, we're just copying in our workload binary from the Pi build + # rather than the generic build. + dockerfile: Dockerfiles/Dockerfile.bel-external-workload + ids: + - pi + image_templates: + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-pi-workload:{{ .Version }}-arm64" + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-pi-workload:latest-arm64" + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-pi-workload:{{ .Version }}" + - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-bel-pi-workload:latest" + build_flag_templates: + - "--platform=linux/arm64" + - "--build-arg=EXTERNAL_BASE={{ .Env.BEL_EXTERNAL_BASE }}" docker_manifests: - name_template: "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}-gui:{{ .Version }}" diff --git a/Dockerfiles/Dockerfile.bel-external-workload b/Dockerfiles/Dockerfile.bel-external-workload new file mode 100644 index 0000000..643d1ad --- /dev/null +++ b/Dockerfiles/Dockerfile.bel-external-workload @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: 2022 Buoyant Inc. +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright 2022-2024 Buoyant Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG EXTERNAL_BASE=you-must-set-the-external-base-arg + +# Build over the external-workload base image. +FROM $EXTERNAL_BASE AS final + +# This is associated with the faces-demo repo. +LABEL org.opencontainers.image.source=https://github.com/BuoyantIO/faces-demo + +# Copy the compiled binary from the builder stage into the final image +COPY --chmod=0755 workload /workload/start diff --git a/Dockerfiles/Dockerfile.external-workload b/Dockerfiles/Dockerfile.external-workload index bbdb5a3..862795c 100644 --- a/Dockerfiles/Dockerfile.external-workload +++ b/Dockerfiles/Dockerfile.external-workload @@ -17,10 +17,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG BASE=ghcr.io/buoyantio/demo-external-base:0.2.0 +ARG EXTERNAL_BASE=you-must-set-the-external-base-arg # Build over the external-workload base image. -FROM $BASE AS final +FROM $EXTERNAL_BASE AS final # This is associated with the faces-demo repo. LABEL org.opencontainers.image.source=https://github.com/BuoyantIO/faces-demo diff --git a/pkg/faces/baseserver.go b/pkg/faces/baseserver.go index 483a5ee..43e0c3a 100644 --- a/pkg/faces/baseserver.go +++ b/pkg/faces/baseserver.go @@ -153,6 +153,7 @@ func (srv *BaseServer) SetupFromEnvironment() { } srv.RegisterCustom("/rl", srv.rlGetHandler) + srv.RegisterCustom("/ready", srv.readyHandler) srv.userHeaderName = utils.StringFromEnv("USER_HEADER_NAME", "X-Faces-User") srv.hostIP = utils.StringFromEnv("HOST_IP", utils.StringFromEnv("HOSTNAME", "unknown")) @@ -350,6 +351,15 @@ func (srv *BaseServer) rlGetHandler(w http.ResponseWriter, r *http.Request) { }) } +func (srv *BaseServer) readyHandler(w http.ResponseWriter, r *http.Request) { + srv.StandardResponse(w, r, &BaseServerResponse{ + StatusCode: http.StatusOK, + Data: map[string]interface{}{ + "ready": true, + }, + }) +} + func (srv *BaseServer) standardGetHandler(w http.ResponseWriter, r *http.Request, userFunc BaseServerHandler) { start := time.Now()