-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tensorflow filter Signed-off-by: kpango <kpango@vdaas.org> * add tensorflow install command to dockerfile Signed-off-by: kpango <kpango@vdaas.org> * fix tensorflow-ingress-filter Signed-off-by: datelier <57349093+datelier@users.noreply.github.com> * fix dockerfile & docker commnad Signed-off-by: datelier <57349093+datelier@users.noreply.github.com> * fix workflow Signed-off-by: datelier <57349093+datelier@users.noreply.github.com> * fix the image-ref field in vulnerability scanner sections Signed-off-by: datelier <57349093+datelier@users.noreply.github.com> Co-authored-by: datelier <57349093+datelier@users.noreply.github.com>
- Loading branch information
Showing
31 changed files
with
3,138 additions
and
83 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
.github/workflows/dockers-filter-ingress-tensorflow.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# | ||
# Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
# | ||
name: "Build docker image: filter-ingress-tensorflow" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "*.*.*" | ||
- "v*.*.*" | ||
- "*.*.*-*" | ||
- "v*.*.*-*" | ||
paths: | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/**/*_mock.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/filter/ingress/tensorflow/**" | ||
- "cmd/filter/ingress/tensorflow/**" | ||
- "dockers/base/Dockerfile" | ||
- "dockers/filter/ingress/tensorflow/Dockerfile" | ||
- "versions/GO_VERSION" | ||
pull_request: | ||
paths: | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/**/*_mock.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/filter/ingress/tensorflow/**" | ||
- "cmd/filter/ingress/tensorflow/**" | ||
- "dockers/base/Dockerfile" | ||
- "dockers/filter/ingress/tensorflow/Dockerfile" | ||
- "versions/GO_VERSION" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
with: | ||
platforms: all | ||
- name: Setup Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
buildkitd-flags: "--debug" | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.PACKAGE_USER }} | ||
password: ${{ secrets.PACKAGE_TOKEN }} | ||
- name: Build and Publish | ||
id: build_and_publish | ||
uses: ./.github/actions/docker-build | ||
with: | ||
target: filter-ingress-tensorflow | ||
builder: ${{ steps.buildx.outputs.name }} | ||
- name: Initialize CodeQL | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: github/codeql-action/init@v1 | ||
- name: Run vulnerability scanner (table) | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}" | ||
format: "table" | ||
- name: Run vulnerability scanner (sarif) | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}" | ||
format: "template" | ||
template: "@/contrib/sarif.tpl" | ||
output: "trivy-results.sarif" | ||
- name: Upload Trivy scan results to Security tab | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: github/codeql-action/upload-sarif@v1 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
slack: | ||
name: Slack notification | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/master' || startsWith( github.ref, 'refs/tags/') | ||
steps: | ||
- uses: technote-space/workflow-conclusion-action@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: 8398a7/action-slack@v2 | ||
with: | ||
author_name: vald-filter-ingress-tensorflow image build | ||
status: ${{ env.WORKFLOW_CONCLUSION }} | ||
only_mention_fail: channel | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> | ||
// | ||
// 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 | ||
// | ||
// https://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. | ||
// | ||
|
||
// Package main provides program main | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/vdaas/vald/internal/errors" | ||
"github.com/vdaas/vald/internal/info" | ||
"github.com/vdaas/vald/internal/log" | ||
"github.com/vdaas/vald/internal/runner" | ||
"github.com/vdaas/vald/internal/safety" | ||
"github.com/vdaas/vald/pkg/filter/ingress/tensorflow/config" | ||
"github.com/vdaas/vald/pkg/filter/ingress/tensorflow/usecase" | ||
) | ||
|
||
const ( | ||
maxVersion = "v0.0.10" | ||
minVersion = "v0.0.0" | ||
name = "tensorflow ingress filter" | ||
) | ||
|
||
func main() { | ||
if err := safety.RecoverFunc(func() error { | ||
return runner.Do( | ||
context.Background(), | ||
runner.WithName(name), | ||
runner.WithVersion(info.Version, maxVersion, minVersion), | ||
runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { | ||
cfg, err := config.NewConfig(path) | ||
if err != nil { | ||
return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") | ||
} | ||
return cfg, &cfg.GlobalConfig, nil | ||
}), | ||
runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { | ||
return usecase.New(cfg.(*config.Data)) | ||
}), | ||
) | ||
})(); err != nil { | ||
log.Fatal(err, info.Get()) | ||
return | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org> | ||
# | ||
# 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 | ||
# | ||
# https://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 GO_VERSION=latest | ||
ARG DISTROLESS_IMAGE=gcr.io/distroless/cc | ||
ARG DISTROLESS_IMAGE_TAG=nonroot | ||
ARG MAINTAINER="vdaas.org vald team <vald@vdaas.org>" | ||
|
||
FROM golang:${GO_VERSION} AS builder | ||
|
||
ENV GO111MODULE on | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV INITRD No | ||
ENV LANG en_US.UTF-8 | ||
ENV ORG vdaas | ||
ENV REPO vald | ||
ENV PKG filter/ingress/tensorflow | ||
ENV APP_NAME tensorflow | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
build-essential \ | ||
cmake \ | ||
upx \ | ||
curl \ | ||
unzip \ | ||
git \ | ||
gcc \ | ||
g++ \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p $GOPATH/src | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
RUN go mod download | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal | ||
COPY internal . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc | ||
COPY apis/grpc . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} | ||
COPY pkg/${PKG} . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} | ||
COPY cmd/${PKG} . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions | ||
COPY versions . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d | ||
COPY Makefile.d . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
COPY Makefile . | ||
COPY .git . | ||
|
||
RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ | ||
&& cp "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" | ||
|
||
FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} | ||
LABEL maintainer "${MAINTAINER}" | ||
|
||
ENV APP_NAME tensorflow | ||
|
||
COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} | ||
COPY --from=builder /usr/local/lib/libtensorflow* /usr/local/lib/ | ||
|
||
ENV LD_LIBRARY_PATH /usr/local/lib | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/go/bin/tensorflow"] |
Oops, something went wrong.