From f3d472cdcc304f45201364d94eb6be217305fb63 Mon Sep 17 00:00:00 2001 From: Jacob Bills Date: Wed, 25 Oct 2023 11:23:26 -0400 Subject: [PATCH 1/4] added dockerfile for testnet. updated readme to reflect hostd similarly --- README.md | 20 ++++++++++++-- docker/Dockerfile.testnet | 58 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 docker/Dockerfile.testnet diff --git a/README.md b/README.md index 25eeff152..411c2890e 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,16 @@ with more configuration options. From within the root of the repo run the following command to build an image of `renterd` tagged `renterd`. -```bash -docker build -t renterd . +### Production + +```sh +docker build -t renterd:latest -f ./docker/Dockerfile . +``` + +### Testnet + +```sh +docker build -t renterd:latest-testnet -f ./docker/Dockerfile.testnet . ``` ### Run Container @@ -54,10 +62,18 @@ docker build -t renterd . Run `renterd` in the background as a container named `renterd` that exposes its API to the host system and the gateway to the world. +### Production + ```bash docker run -d --name renterd -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ``` +### Testnet + +```bash +docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp renterd:latest-testnet +``` + ## Usage Guidelines The Web UI streamlines the initial setup and configuration for newcomers. diff --git a/docker/Dockerfile.testnet b/docker/Dockerfile.testnet new file mode 100644 index 000000000..e40d0fdc7 --- /dev/null +++ b/docker/Dockerfile.testnet @@ -0,0 +1,58 @@ +# Helper image to build renterd. +FROM golang:1.21 AS builder + +# Define arguments for build tags and to skip running go generate. +ARG BUILD_TAGS='testnet netgo' \ + BUILD_RUN_GO_GENERATE='true' + +# Set the working directory. +WORKDIR /renterd + +# Copy over the go mod and sum files +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy the rest of the application code +COPY . . + +# Generate build metadata. +RUN if [ "$BUILD_RUN_GO_GENERATE" = "true" ] ; then go generate ./... ; fi + +# Build renterd. +RUN --mount=type=cache,target=/root/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + CGO_ENABLED=1 go build -ldflags="-s -w" -tags="${BUILD_TAGS}" ./cmd/renterd + +# Build image that will be used to run renterd. +FROM debian:bookworm-slim +LABEL maintainer="The Sia Foundation " \ + org.opencontainers.image.description.vendor="The Sia Foundation" \ + org.opencontainers.image.description="A renterd container - next-generation Sia renter" \ + org.opencontainers.image.source="https://github.com/SiaFoundation/renterd" \ + org.opencontainers.image.licenses=MIT + +# User to run renterd as. Defaults to root. +ENV PUID=0 +ENV PGID=0 + +# Entrypoint env args +ARG BUILD_TAGS +ENV BUILD_TAGS=$BUILD_TAGS + +# Renterd env args +ENV RENTERD_API_PASSWORD= +ENV RENTERD_SEED= +ENV RENTERD_CONFIG_FILE=/data/renterd.yml + +# Copy binary and prepare data dir. +COPY --from=builder /renterd/renterd /usr/bin/renterd +VOLUME [ "/data" ] + +USER ${PUID}:${PGID} + +# Copy the script and set it as the entrypoint. +COPY docker/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh", "-dir", "./data", "--http", ":9880"] From 807355b1e6045a0d977c8ecd89a1f7a646ac124f Mon Sep 17 00:00:00 2001 From: Jacob Bills Date: Thu, 26 Oct 2023 11:52:14 -0400 Subject: [PATCH 2/4] changed docker run statements to use images out of ghcr.io/siafoundation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 411c2890e..762443bfc 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,13 @@ API to the host system and the gateway to the world. ### Production ```bash -docker run -d --name renterd -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp +docker run -d --name renterd -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:latest ``` ### Testnet ```bash -docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp renterd:latest-testnet +docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp ghcr.io/siafoundation/renterd:latest-testnet ``` ## Usage Guidelines From 2ececf9b96c6fd1250d65371e0562669af0dac96 Mon Sep 17 00:00:00 2001 From: Jacob Bills Date: Mon, 30 Oct 2023 22:03:55 -0400 Subject: [PATCH 3/4] removed testnet dockerfile. updated build commands to include respective docker tags for mainnet/testnet --- README.md | 4 +-- docker/Dockerfile.testnet | 58 --------------------------------------- 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 docker/Dockerfile.testnet diff --git a/README.md b/README.md index 762443bfc..1d8c30482 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ From within the root of the repo run the following command to build an image of ### Production ```sh -docker build -t renterd:latest -f ./docker/Dockerfile . +docker build --build-arg BUILD_TAGS='netgo' -t renterd:latest -f ./docker/Dockerfile . ``` ### Testnet ```sh -docker build -t renterd:latest-testnet -f ./docker/Dockerfile.testnet . +docker build --build-arg BUILD_TAGS='netgo testnet' -t renterd-testnet:latest -f ./docker/Dockerfile . ``` ### Run Container diff --git a/docker/Dockerfile.testnet b/docker/Dockerfile.testnet deleted file mode 100644 index e40d0fdc7..000000000 --- a/docker/Dockerfile.testnet +++ /dev/null @@ -1,58 +0,0 @@ -# Helper image to build renterd. -FROM golang:1.21 AS builder - -# Define arguments for build tags and to skip running go generate. -ARG BUILD_TAGS='testnet netgo' \ - BUILD_RUN_GO_GENERATE='true' - -# Set the working directory. -WORKDIR /renterd - -# Copy over the go mod and sum files -COPY go.mod go.sum ./ - -# Download dependencies -RUN go mod download - -# Copy the rest of the application code -COPY . . - -# Generate build metadata. -RUN if [ "$BUILD_RUN_GO_GENERATE" = "true" ] ; then go generate ./... ; fi - -# Build renterd. -RUN --mount=type=cache,target=/root/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=1 go build -ldflags="-s -w" -tags="${BUILD_TAGS}" ./cmd/renterd - -# Build image that will be used to run renterd. -FROM debian:bookworm-slim -LABEL maintainer="The Sia Foundation " \ - org.opencontainers.image.description.vendor="The Sia Foundation" \ - org.opencontainers.image.description="A renterd container - next-generation Sia renter" \ - org.opencontainers.image.source="https://github.com/SiaFoundation/renterd" \ - org.opencontainers.image.licenses=MIT - -# User to run renterd as. Defaults to root. -ENV PUID=0 -ENV PGID=0 - -# Entrypoint env args -ARG BUILD_TAGS -ENV BUILD_TAGS=$BUILD_TAGS - -# Renterd env args -ENV RENTERD_API_PASSWORD= -ENV RENTERD_SEED= -ENV RENTERD_CONFIG_FILE=/data/renterd.yml - -# Copy binary and prepare data dir. -COPY --from=builder /renterd/renterd /usr/bin/renterd -VOLUME [ "/data" ] - -USER ${PUID}:${PGID} - -# Copy the script and set it as the entrypoint. -COPY docker/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh", "-dir", "./data", "--http", ":9880"] From 421de9a9b20e4b6fc14d9a70e46a1766b9bb8f3c Mon Sep 17 00:00:00 2001 From: Jacob Bills Date: Tue, 31 Oct 2023 11:11:29 -0400 Subject: [PATCH 4/4] remove build tags from main docker build. renamed image names for consistency --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1d8c30482..2c4b0504f 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ From within the root of the repo run the following command to build an image of ### Production ```sh -docker build --build-arg BUILD_TAGS='netgo' -t renterd:latest -f ./docker/Dockerfile . +docker build -t renterd:master -f ./docker/Dockerfile . ``` ### Testnet ```sh -docker build --build-arg BUILD_TAGS='netgo testnet' -t renterd-testnet:latest -f ./docker/Dockerfile . +docker build --build-arg BUILD_TAGS='netgo testnet' -t renterd:master-zen -f ./docker/Dockerfile . ``` ### Run Container @@ -65,13 +65,13 @@ API to the host system and the gateway to the world. ### Production ```bash -docker run -d --name renterd -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:latest +docker run -d --name renterd -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:master ``` ### Testnet ```bash -docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp ghcr.io/siafoundation/renterd:latest-testnet +docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="" -e RENTERD_SEED="" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp ghcr.io/siafoundation/renterd:master-zen ``` ## Usage Guidelines