diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..e940eff --- /dev/null +++ b/.env-example @@ -0,0 +1,4 @@ +CERBERUS_HOME=${HOME}/cerberus +CERBERUS_KEYSTORE_DIR=${CERBERUS_HOME}/data/keystore +CERBERUS_GRPC_PORT=50051 +CERBERUS_METRICS_PORT=9081 diff --git a/.gitignore b/.gitignore index ceb3176..e306362 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ +.env data/ - bin/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 315acb5..81bbe65 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -35,7 +35,7 @@ dockers: - ghcr.io/layr-labs/{{ .ProjectName }}:latest-amd64 - ghcr.io/layr-labs/{{ .ProjectName }}:{{.Version}}-amd64 use: buildx - dockerfile: Dockerfile + dockerfile: Dockerfile.goreleaser build_flag_templates: - "--platform=linux/amd64" - "--build-arg=APP_VERSION={{ .Version }}" @@ -44,7 +44,7 @@ dockers: - ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64 - ghcr.io/layr-labs/{{ .ProjectName }}:{{.Version}}-arm64 use: buildx - dockerfile: Dockerfile + dockerfile: Dockerfile.goreleaser build_flag_templates: - "--platform=linux/arm64" - "--build-arg=APP_VERSION={{ .Version }}" @@ -58,4 +58,4 @@ docker_manifests: - name_template: ghcr.io/layr-labs/{{ .ProjectName }}:latest image_templates: - ghcr.io/layr-labs/{{ .ProjectName }}:latest-amd64 - - ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64 \ No newline at end of file + - ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64 diff --git a/Dockerfile b/Dockerfile index 8f94509..799caf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ -#FROM golang:1.21 AS build -# -#WORKDIR /usr/src/app -# -#COPY go.mod go.sum ./ -# -#RUN go mod download && go mod tidy && go mod verify -# -#COPY . . -# -#ARG APP_VERSION -#RUN go build -ldflags "-X main.version=$APP_VERSION" -v -o bin/cerberus cmd/cerberus/main.go +FROM golang:1.21 AS build + +WORKDIR /usr/src/app + +COPY go.mod go.sum ./ + +RUN go mod download && go mod tidy && go mod verify + +COPY . . + +ARG APP_VERSION +RUN go build -ldflags "-X main.version=$APP_VERSION" -v -o bin/cerberus cmd/cerberus/main.go FROM debian:latest -COPY cerberus /cerberus +COPY bin/cerberus /cerberus -ENTRYPOINT [ "/cerberus"] \ No newline at end of file +ENTRYPOINT [ "/cerberus"] diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser new file mode 100644 index 0000000..592356d --- /dev/null +++ b/Dockerfile.goreleaser @@ -0,0 +1,17 @@ +#FROM golang:1.21 AS build +# +#WORKDIR /usr/src/app +# +#COPY go.mod go.sum ./ +# +#RUN go mod download && go mod tidy && go mod verify +# +#COPY . . +# +#ARG APP_VERSION +#RUN go build -ldflags "-X main.version=$APP_VERSION" -v -o bin/cerberus cmd/cerberus/main.go + +FROM debian:latest +COPY cerberus /cerberus + +ENTRYPOINT [ "/cerberus"] diff --git a/Makefile b/Makefile index 0e858d1..8f01273 100644 --- a/Makefile +++ b/Makefile @@ -31,4 +31,8 @@ lint: ## runs all linters .PHONY: tests tests: ## runs all tests - go test ./... -covermode=atomic \ No newline at end of file + go test ./... -covermode=atomic + +.PHONY: docker +docker: ## runs docker build + docker build -t $(APP_NAME):latest . diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7f789cb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.8' +services: + cerberus: + image: cerberus:latest + container_name: cerberus + ports: + - "${CERBERUS_METRICS_PORT}:${CERBERUS_METRICS_PORT}" + - "${CERBERUS_GRPC_PORT}:${CERBERUS_GRPC_PORT}" + environment: + - "KEYSTORE_DIR=/keystore" + - "METRICS_PORT=${CERBERUS_METRICS_PORT}" + volumes: + - "${CERBERUS_KEYSTORE_DIR}:/keystore" + env_file: + - .env + restart: unless-stopped diff --git a/internal/store/filesystem/filesystem.go b/internal/store/filesystem/filesystem.go index 158bb01..91c61bd 100644 --- a/internal/store/filesystem/filesystem.go +++ b/internal/store/filesystem/filesystem.go @@ -35,7 +35,7 @@ func NewStore( logger.Error(fmt.Sprintf("Error creating keystore directory: %v", err)) os.Exit(1) } - logger.Info("Created keystore directory successfully") + logger.Info("Created keystore directory successfully", "keystore", keystoreDir) return &FileStore{ keystoreDir: keystoreDir, logger: logger,