Skip to content

Commit

Permalink
Adds minimal docker compose (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork authored Nov 19, 2024
1 parent b73b9ec commit 64c1817
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 20 deletions.
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
#
#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

0 comments on commit 64c1817

Please sign in to comment.