Skip to content

Commit

Permalink
quaybackstop: add backstop GC command
Browse files Browse the repository at this point in the history
This command should allow a Clair+Quay system to periodically ensure
that the Clair database is not continuing to store manifests that no
longer exist in the Quay database.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Sep 4, 2024
1 parent c31e40e commit e5e7ba5
Show file tree
Hide file tree
Showing 10 changed files with 1,113 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ NOTICE
# Directories
/book
/contrib
!/contrib/cmd
/Documenatation
/etc
/local-dev
Expand Down
56 changes: 56 additions & 0 deletions contrib/cmd/quaybackstop/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# syntax=docker.io/docker/dockerfile:1.7

# Copyright 2024 clair authors
#
# 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.

# This Dockerfile expects the context to be the root of the repo, e.g.:
# go run github.com/moby/buildkit/cmd/buildctl@latest build \
# --frontend dockerfile.v0 \
# --local context=. --local dockerfile=contrib/cmd/quaybackstop

ARG GOTOOLCHAIN=local
ARG GO_VERSION=1.23
FROM --platform=$BUILDPLATFORM quay.io/projectquay/golang:${GO_VERSION} AS build
WORKDIR /build
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=go.sum,target=go.sum \
go mod download

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--network=none \
<<.
set -e
export GOOS="$TARGETOS" GOARCH="$TARGETARCH" GOBIN=/out/bin CGO_ENABLED=0
if [ -n "$TARGETVARIANT" ]; then
case "$TARGETARCH" in
amd64) export GOAMD64="$TARGETVARIANT" ;;
ppc64*) export GOPPC64="$TARGETVARIANT" ;;
esac
fi
install -d "${GOBIN}"
go build -ldflags="-s -w" -trimpath -o "${GOBIN}" ./contrib/cmd/quaybackstop
.

FROM gcr.io/distroless/static:nonroot AS final
COPY --from=build /out/bin/quaybackstop /
WORKDIR /run
USER 65532:65532
ENTRYPOINT ["/quaybackstop"]
Loading

0 comments on commit e5e7ba5

Please sign in to comment.