Skip to content

Commit

Permalink
Merge pull request #566 from SiaFoundation/nate/docker-base-image
Browse files Browse the repository at this point in the history
Switch Docker base from scratch to debian:slim
  • Loading branch information
n8maninger authored Jan 11, 2025
2 parents 49c373f + 449c29c commit f368cce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: major
---

# Switched Docker base image from scratch to debian:bookworm-slim
29 changes: 12 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/golang:1.23 AS builder
FROM golang:1.23 AS builder

WORKDIR /hostd

Expand All @@ -11,29 +11,24 @@ 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/hostd
RUN CGO_ENABLED=1 go build -o bin/ -tags='timetzdata' -trimpath -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/hostd

FROM scratch
FROM debian:bookworm-slim

LABEL maintainer="The Sia Foundation <[email protected]>" \
org.opencontainers.image.description.vendor="The Sia Foundation" \
org.opencontainers.image.description="A hostd container - provide storage on the Sia network and earn Siacoin" \
org.opencontainers.image.source="https://github.com/SiaFoundation/hostd" \
org.opencontainers.image.licenses=MIT
org.opencontainers.image.description.vendor="The Sia Foundation" \
org.opencontainers.image.description="A hostd container - provide storage on the Sia network and earn Siacoin" \
org.opencontainers.image.source="https://github.com/SiaFoundation/hostd" \
org.opencontainers.image.licenses=MIT

ENV PUID=0
ENV PGID=0
# copy binary and certificates
COPY --from=builder /hostd/bin/* /usr/bin/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENV HOSTD_API_PASSWORD=
ENV HOSTD_WALLET_SEED=
ENV HOSTD_DATA_DIR=/data
ENV HOSTD_CONFIG_FILE=/data/hostd.yml

# copy binary and prepare data dir.
COPY --from=builder /hostd/bin/* /usr/bin/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
VOLUME [ "/data" ]

# API port
EXPOSE 9980/tcp
# RPC port
Expand All @@ -42,7 +37,7 @@ EXPOSE 9981/tcp
EXPOSE 9982/tcp
# RHP3 TCP port
EXPOSE 9983/tcp

USER ${PUID}:${PGID}
# RHP4 TCP port
EXPOSE 9984/tcp

ENTRYPOINT [ "hostd", "--env", "--http", ":9980" ]
6 changes: 3 additions & 3 deletions cmd/hostd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func defaultDataDirectory(fp string) string {

// check for databases in the current directory
if _, err := os.Stat("hostd.db"); err == nil {
return ""
return "."
} else if _, err := os.Stat("hostd.sqlite3"); err == nil {
return ""
return "."
}

// default to the operating system's application directory
Expand All @@ -64,7 +64,7 @@ func defaultDataDirectory(fp string) string {
case "linux", "freebsd", "openbsd":
return filepath.Join(string(filepath.Separator), "var", "lib", "hostd")
default:
return ""
return "."
}
}

Expand Down

0 comments on commit f368cce

Please sign in to comment.