Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds minimal docker compose #10

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CERBERUS_HOME=${HOME}/cerberus
CERBERUS_KEYSTORE_DIR=${CERBERUS_HOME}/data/keystore
CERBERUS_GRPC_PORT=50051
CERBERUS_METRICS_PORT=9081
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
data/

bin/
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}"
Expand All @@ -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
- ghcr.io/layr-labs/{{ .ProjectName }}:latest-arm64
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#FROM golang:1.21 AS build
#
shrimalmadhur marked this conversation as resolved.
Show resolved Hide resolved
#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"]
ENTRYPOINT [ "/cerberus"]
17 changes: 17 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ lint: ## runs all linters

.PHONY: tests
tests: ## runs all tests
go test ./... -covermode=atomic
go test ./... -covermode=atomic

.PHONY: docker
docker: ## runs docker build
docker build -t $(APP_NAME):latest .
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion internal/store/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading