Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 19, 2024
1 parent ed38ff9 commit 2fa4104
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM docker.io/library/golang:1.23 AS builder

WORKDIR /app

# get dependencies
COPY go.mod go.sum ./
RUN go mod download

# copy source
COPY . .
# codegen
RUN go generate ./...
# build
RUN CGO_ENABLED=1 go build -o bin/ -tags='netgo timetzdata' -trimpath -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/clusterd

FROM debian:bookworm-slim

LABEL maintainer="The Sia Foundation <[email protected]>" \
org.opencontainers.image.description.vendor="The Sia Foundation" \
org.opencontainers.image.description="A cluster container for testing a local Sia network" \
org.opencontainers.image.source="https://github.com/SiaFoundation/hostd" \
org.opencontainers.image.licenses=MIT

ENV PUID=0
ENV PGID=0

# copy binary and prepare data dir.
COPY --from=builder /app/bin/* /usr/bin/
VOLUME [ "/data" ]

EXPOSE 3000

USER ${PUID}:${PGID}

ENTRYPOINT [ "clusterd" ]
10 changes: 7 additions & 3 deletions cmd/clusterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func main() {
flag.StringVar(&network, "network", "v1", "network to use (v1 or v2)")
flag.StringVar(&siafundAddr, "siafund", "", "address to send siafunds to")

flag.IntVar(&renterdCount, "renterd", 1, "number of renter daemons to run")
flag.IntVar(&hostdCount, "hostd", 1, "number of host daemons to run")
flag.IntVar(&walletdCount, "walletd", 1, "number of wallet daemons to run")
flag.IntVar(&renterdCount, "renterd", 0, "number of renter daemons to run")
flag.IntVar(&hostdCount, "hostd", 0, "number of host daemons to run")
flag.IntVar(&walletdCount, "walletd", 0, "number of wallet daemons to run")
flag.Parse()

cfg := zap.NewProductionEncoderConfig()
Expand Down Expand Up @@ -79,6 +79,10 @@ func main() {

zap.RedirectStdLog(log)

if hostdCount == 0 && renterdCount == 0 && walletdCount == 0 {
log.Panic("no nodes to run")
}

ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()

Expand Down

0 comments on commit 2fa4104

Please sign in to comment.