Skip to content

Commit

Permalink
Remove several unused build files and update the docker images to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtw committed Oct 31, 2022
1 parent 0b085ab commit 8fa3a7f
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ metric:
# (Optional)
subsystem: "caduceus"

touchstone:
# DefaultNamespace is the prometheus namespace to apply when a metric has no namespace
defaultNamespace: "xmidt"
# DefaultSubsystem is the prometheus subsystem to apply when a metric has no subsystem
defaultSubsystem: "caduceus"

########################################
# Service Discovery Configuration
########################################
Expand Down Expand Up @@ -212,6 +218,35 @@ log:
# (Optional) defaults to false
json: true

zap:
# OutputPaths is a list of URLs or file paths to write logging output to.
outputPaths:
- stdout
# - /var/log/caduceus/caduceus.log

# Level is the minimum enabled logging level. Note that this is a dynamic
# level, so calling Config.Level.SetLevel will atomically change the log
# level of all loggers descended from this config.
level: debug

# EncoderConfig sets options for the chosen encoder. See
# zapcore.EncoderConfig for details.
errorOutputPaths:
- stderr
# - /var/log/caduceus/caduceus.log

# EncoderConfig sets options for the chosen encoder. See
# zapcore.EncoderConfig for details.
encoderConfig:
messageKey: message
levelKey: key
levelEncoder: lowercase

# Encoding sets the logger's encoding. Valid values are "json" and
# "console", as well as any third-party encodings registered via
# RegisterEncoder.
encoding: json

########################################
# Authorization Related Configuration
########################################
Expand Down Expand Up @@ -283,7 +318,9 @@ webhook:
# Raw: parser assumes all of the token payload == JWT token
# (Optional). Defaults to 'simple'.
JWTParserType: (( grab $WEBHOOK_JWT_PARSER_TYPE || "raw" ))
argus:
BasicClientConfig:
# listen is the subsection that configures the listening feature of the argus client
# (Optional)
listen:
# pullInterval is how often to call argus to update the webhook structure.
pullInterval: (( grab $ARGUS_PULL_INTERVAL || "5s" ))
Expand Down Expand Up @@ -352,6 +389,13 @@ sender:
# (Deprecated)
# clientTimeout: 60s

# disableClientHostnameValidation provides a way to bypass TLS validation
# failures on HTTPS requests when sending events to webhooks.
# NOTE: Setting this to true allows for a potential man-in-the-middle
# scenario between caduceus and a webhook.
# (Optional) defaults to false
disableClientHostnameValidation: false

# deliveryRetries is the maximum number of delivery attempts caduceus will
# make before dropping an event
deliveryRetries: 1
Expand All @@ -363,7 +407,7 @@ sender:
# responseHeaderTimeout is the time to wait for a response before giving up
# and marking the delivery a failure
responseHeaderTimeout: 10s

# customPIDs is a custom list of allowed PartnerIDs that will be used if a message
# has no partner IDs. When empty, a message with no partner IDs will not be sent
# to any listeners when enforcing the partner ID check.
Expand Down Expand Up @@ -415,4 +459,4 @@ argusClientTimeout:
# the API at the same time from the same application. When this is true,
# caduceus will support both "/v3" and "/v4" endpoints. When false, only "/v4"
# endpoints will be supported.
previousVersionSupport: (( grab $PREV_VERSION_SUPPORT || true ))
previousVersionSupport: (( grab $PREV_VERSION_SUPPORT || true ))
37 changes: 37 additions & 0 deletions .release/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh
set -e

# check arguments for an option that would cause /caduceus to stop
# return true if there is one
_want_help() {
local arg
for arg; do
case "$arg" in
-'?'|--help|-v)
return 0
;;
esac
done
return 1
}

_main() {
# if command starts with an option, prepend caduceus
if [ "${1:0:1}" = '-' ]; then
set -- /caduceus "$@"
fi

# skip setup if they aren't running /caduceus or want an option that stops /caduceus
if [ "$1" = '/caduceus' ] && ! _want_help "$@"; then
echo "Entrypoint script for caduceus Server ${VERSION} started."

if [ ! -s /etc/caduceus/caduceus.yaml ]; then
echo "Building out template for file"
/bin/spruce merge /tmp/caduceus_spruce.yaml > /etc/caduceus/caduceus.yaml
fi
fi

exec "$@"
}

_main "$@"
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 28 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,40 @@ RUN apk add --no-cache --no-progress \
libc-dev \
upx

# Download spruce here to eliminate the need for curl in the final image
RUN mkdir -p /go/bin && \
curl -o /go/bin/spruce https://github.com/geofffranks/spruce/releases/download/v1.29.0/spruce-linux-amd64 && \
curl -L -o /go/bin/spruce https://github.com/geofffranks/spruce/releases/download/v1.29.0/spruce-linux-amd64 && \
chmod +x /go/bin/spruce

COPY . .

RUN make test release

FROM alpine:3.12.1
##########################
# Build the final image.
##########################

FROM alpine:latest

# Copy over the standard things you'd expect.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /src/caduceus /
COPY --from=builder /src/.release/docker/entrypoint.sh /

# Copy over spruce and the spruce template file used to make the actual configuration file.
COPY --from=builder /src/.release/docker/caduceus_spruce.yaml /tmp/caduceus_spruce.yaml
COPY --from=builder /go/bin/spruce /bin/

# Include compliance details about the container and what it contains.
COPY --from=builder /src/Dockerfile \
/src/NOTICE \
/src/LICENSE \
/src/CHANGELOG.md /

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /src/caduceus /src/caduceus.yaml /src/deploy/packaging/entrypoint.sh /go/bin/spruce /src/Dockerfile /src/NOTICE /src/LICENSE /src/CHANGELOG.md /
COPY --from=builder /src/deploy/packaging/caduceus_spruce.yaml /tmp/caduceus_spruce.yaml
COPY --from=builder /src/caduceus.yaml /etc/caduceus/caduceus.yaml
# Make the location for the configuration file that will be used.
RUN mkdir /etc/caduceus/ \
&& touch /etc/caduceus/caduceus.yaml \
&& chmod 666 /etc/caduceus/caduceus.yaml

USER nobody

Expand Down
20 changes: 9 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@


DOCKER ?= docker
GO ?= go
GOFMT ?= $(GO)fmt
APP := caduceus
DOCKER_ORG := xmidt
DOCKER_ORG := ghcr.io/xmidt-org

VERSION ?= $(shell git describe --tag --always --dirty)
PROGVER ?= $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/')
Expand All @@ -16,21 +14,21 @@ GOBUILDFLAGS = -a -ldflags "-w -s -X 'main.BuildTime=$(BUILDTIME)' -X main.GitCo
default: build

generate:
$(GO) generate ./...
$(GO) install ./...
go generate ./...
go install ./...

test:
$(GO) test -v -race -coverprofile=coverage.txt ./...
$(GO) test -v -race -json ./... > report.json
go test -v -race -coverprofile=coverage.txt ./...
go test -v -race -json ./... > report.json

style:
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
! gofmt -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'

check:
golangci-lint run -n | tee errors.txt

build:
CGO_ENABLED=0 $(GO) build $(GOBUILDFLAGS)
CGO_ENABLED=0 go build $(GOBUILDFLAGS)

release: build
upx $(APP)
Expand All @@ -42,8 +40,8 @@ docker:

binaries: generate
mkdir -p ./.ignore
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"

upx ./.ignore/$(APP)-$(PROGVER).darwin-amd64
upx ./.ignore/$(APP)-$(PROGVER).linux-amd64
Expand Down
6 changes: 0 additions & 6 deletions conf/caduceus.env.example

This file was deleted.

18 changes: 0 additions & 18 deletions conf/caduceus.service

This file was deleted.

90 changes: 0 additions & 90 deletions deploy/packaging/caduceus.spec

This file was deleted.

49 changes: 0 additions & 49 deletions deploy/packaging/entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions rpkg.conf

This file was deleted.

Loading

0 comments on commit 8fa3a7f

Please sign in to comment.