Skip to content

Commit

Permalink
Merge branch 'main' into uci/copy-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh authored Aug 13, 2024
2 parents 1332bc4 + b280faa commit 8b98b4d
Show file tree
Hide file tree
Showing 15 changed files with 962 additions and 586 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@ jobs:
shell: bash
steps:
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.20.4
- uses: actions/checkout@v3
go-version: 1.22.x
- uses: actions/checkout@v4
with:
path: 'ipfs-check'
- name: Build and Start
run: |
cd ipfs-check
go build -o ipfs-check
./ipfs-check &
sleep 300
- uses: ipfs/download-ipfs-distribution-action@v1
- name: Configure Kubo Gateway
run: |
ipfs init;
- uses: ipfs/start-ipfs-daemon-action@v1
- name: Tests
working-directory: ipfs-check
run: |
Expand Down
50 changes: 42 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
FROM cimg/go:1.19.1
USER circleci
RUN mkdir -p /home/circleci/app
WORKDIR /home/circleci/app
COPY --chown=circleci:circleci *.go go.mod go.sum ./
EXPOSE 3333
RUN go build
CMD [ "./ipfs-check" ]
# Builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21-bookworm AS builder

LABEL org.opencontainers.image.source=https://github.com/ipfs-shipyard/ipfs-check
LABEL org.opencontainers.image.description="Check if you can find your content on IPFS"
LABEL org.opencontainers.image.licenses=MIT+APACHE_2.0

ARG TARGETPLATFORM TARGETOS TARGETARCH

ENV GOPATH /go
ENV SRC_PATH $GOPATH/src/github.com/ipfs-shipyard/ipfs-check
ENV GO111MODULE on
ENV GOPROXY https://proxy.golang.org

COPY go.* $SRC_PATH/
WORKDIR $SRC_PATH
RUN go mod download

COPY . $SRC_PATH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o $GOPATH/bin/ipfs-check

# Runner
FROM debian:bookworm-slim

RUN apt-get update && \
apt-get install --no-install-recommends -y tini ca-certificates curl && \
rm -rf /var/lib/apt/lists/*

ENV GOPATH /go
ENV SRC_PATH $GOPATH/src/github.com/ipfs-shipyard/ipfs-check
ENV DATA_PATH /data/ipfs-check

COPY --from=builder $GOPATH/bin/ipfs-check /usr/local/bin/ipfs-check

RUN mkdir -p $DATA_PATH && \
useradd -d $DATA_PATH -u 1000 -G users ipfs && \
chown ipfs:users $DATA_PATH
VOLUME $DATA_PATH
WORKDIR $DATA_PATH

USER ipfs
ENTRYPOINT ["tini", "--", "/usr/local/bin/ipfs-check", "start"]
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
ipfs-check
=======================
# ipfs-check

> Check if you can find your content on IPFS
A tool for checking the accessibility of your data by IPFS peers
A debugging tool for checking the retrievability of data by IPFS peers

## Documentation


### Build

`go build` will build the server binary in your local directory

### Install

`go install` will build and install the server binary in your global Go binary directory (e.g. `~/go/bin`)

### Deploy

There are web assets in `web` that interacts with the Go HTTP server that can be deployed however you deploy web assets.
There are web assets in `web` that interact with the Go HTTP server that can be deployed however you deploy web assets.
Maybe just deploy it on IPFS and reference it with DNSLink.

For anything other than local testing you're going to want to have a proxy to give you HTTPS support on the Go server.

When deploying to prod, since the addition of telemetry (https://github.com/ipfs-shipyard/ipfs-check/pull/30) you will also need to run the following before serving the web assets:

```
cd web
npm install && npm run build
Expand All @@ -42,18 +42,37 @@ docker run -d ipfs-check
## Running locally

### Terminal 1

```
go build
./ipfs-check # Note listening port.. output should say something like "listening on [::]:3333"
```

### Terminal 2

```
# feel free to use any other tool to serve the contents of the /web folder (you can open the html file directly in your browser)
npx -y serve -l 3000 web
# Then open http://localhost:3000?backendUrl=http://localhost:3333
# Then open http://localhost:3000?backendURL=http://localhost:3333
```

## Metrics

The ipfs-check server is instrumented and exposes two Prometheus metrics endpoints:

- `/metrics/libp2p` exposes [go-libp2p metrics](https://blog.libp2p.io/2023-08-15-metrics-in-go-libp2p/).
- `/metrics/http` exposes http metrics for the check endpoint.

### Securing the metrics endpoints

To add HTTP basic auth to the two metrics endpoints, you can use the `--metrics-auth-username` and `--metrics-auth-password` flags:

```
./ipfs-check --metrics-auth-username=user --metrics-auth-password=pass
```

Alternatively, you can use the `IPFS_CHECK_METRICS_AUTH_USER` and `IPFS_CHECK_METRICS_AUTH_PASS` env vars.

## License

[SPDX-License-Identifier: Apache-2.0 OR MIT](LICENSE.md)
167 changes: 0 additions & 167 deletions bitswap.go

This file was deleted.

Loading

0 comments on commit 8b98b4d

Please sign in to comment.