Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another attempt to replace go-bindata with //go:embed #460

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@ on:
# Run CI for PRs to main and staging
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
go-build:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18", "1.17", "1.14"]
go: ["1.18", "1.17", "1.16"]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
- uses: actions/setup-node@v3
with:
go-version: ${{ matrix.go }}
- run: go build -x -work ./cmds/...
node-build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-node@v1
node-version: current
- uses: actions/setup-go@v3
with:
node-version: "10.x"
- run: npm install
go-version: ${{ matrix.go }}
- run: make
docker-build:
name: Create docker image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -71,6 +67,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: current
- run: make ui
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
Expand All @@ -79,15 +79,19 @@ jobs:
with:
version: v1.46.2

go-test:
test:
strategy:
matrix:
go: ["1.18", "1.17", "1.14"]
go: ["1.18", "1.17", "1.16"]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
- uses: actions/setup-node@v3
with:
node-version: current
- run: make ui
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: go test -race ./...
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/.idea
dist/
config.json
/ui/.build
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ FROM alpine:3.16

ENV GOPATH /go

COPY . /go/src/github.com/hound-search/hound
COPY . /src

RUN apk update \
&& apk add go git subversion libc-dev mercurial breezy openssh tini build-base \
&& cd /go/src/github.com/hound-search/hound \
&& go mod download \
&& go install github.com/hound-search/hound/cmds/houndd \
&& apk del go build-base \
&& rm -f /var/cache/apk/* \
&& rm -rf /go/src /go/pkg
&& apk add go git subversion libc-dev mercurial breezy openssh tini build-base npm rsync \
&& cd /src \
&& make \
&& cp .build/bin/houndd /bin \
&& rm -r .build \
&& apk del go build-base rsync npm \
&& rm -f /var/cache/apk/*

VOLUME ["/data"]

EXPOSE 6080

ENTRYPOINT ["/sbin/tini", "--", "/go/bin/houndd", "-conf", "/data/config.json"]
ENTRYPOINT ["/sbin/tini", "--", "/bin/houndd", "-conf", "/data/config.json"]
18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CMDS := .build/bin/houndd .build/bin/hound

SRCS := $(shell find . -type f -name '*.go')
UI := $(shell find ui/assets -type f)

WEBPACK_ARGS := --mode production
ifdef DEBUG
Expand All @@ -9,27 +10,24 @@ endif

ALL: $(CMDS)

ui: ui/bindata.go
ui: ui/.build/ui

# the mtime is updated on a directory when its files change so it's better
# to rely on a single file to represent the presence of node_modules.
node_modules/build:
npm install
date -u >> $@

.build/bin/houndd: ui/bindata.go $(SRCS)
.build/bin/houndd: ui/.build/ui $(SRCS)
go build -o $@ github.com/hound-search/hound/cmds/houndd

.build/bin/hound: ui/bindata.go $(SRCS)
.build/bin/hound: $(SRCS)
go build -o $@ github.com/hound-search/hound/cmds/hound

.build/bin/go-bindata:
go build -o $@ github.com/go-bindata/go-bindata/go-bindata

ui/bindata.go: .build/bin/go-bindata node_modules/build $(wildcard ui/assets/**/*)
rsync -r ui/assets/* .build/ui
ui/.build/ui: node_modules/build $(UI)
mkdir -p ui/.build/ui
cp -r ui/assets/* ui/.build/ui
npx webpack $(WEBPACK_ARGS)
$< -o $@ -pkg ui -prefix .build/ui -nomemcopy .build/ui/...

dev: node_modules/build

Expand All @@ -45,4 +43,4 @@ lint:
golangci-lint run ./...

clean:
rm -rf .build node_modules
rm -rf .build ui/.build node_modules
74 changes: 43 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,21 @@ Hound is an extremely fast source code search engine. The core is based on this

## Quick Start Guide

### Using Go Tools
### Building hound

0. Install [go](https://go.dev/) (minimum version required: 1.16) and [npm](https://github.com/npm/cli/#installation)

0. [Install Go](https://golang.org/doc/install) if you don't have it already. Hound requires version 1.4 or later.
You might also want to define a [`GOPATH`](https://github.com/golang/go/wiki/GOPATH) environment variable)
(it defaults to $HOME/go if you don't explicitly have one set). If everything is installed properly, `go version` should
print out the installed version of go.

1. Use the Go tools to install Hound. The binaries `houndd` (server) and `hound` (cli) will be installed in your $GOPATH/bin directory. Your $GOPATH should be in your $PATH (`echo $PATH` to check).

```
go get github.com/hound-search/hound/cmds/...
```

If the above doesn't work for you, try to install hound manually with the following:
1. Clone the repository and run make.

```
git clone https://github.com/hound-search/hound.git
cd hound
go build ./cmds/hound
go build ./cmds/houndd
sudo mv hound houndd ~/go/bin/
make
```

You might have to change the path of the last command if you installed Go somewhere else on your system.
The resulting binaries (`hound`, `houndd`) can be found in the .build/bin/ directory.

2. Create a config.json file in your `$GOPATH/bin` and use it to list your repositories. Check out our [example-config.json](config-example.json)
2. Create a config.json file and use it to list your repositories. Check out our [example-config.json](config-example.json)
to see how to set up various types of repositories. For example, we can configure Hound to search its own source code using
the config found in [default-config.json](default-config.json):

Expand All @@ -52,7 +40,7 @@ the config found in [default-config.json](default-config.json):

A complete list of available config options can be found [here](docs/config-options.md).

3. Run the Hound server with `houndd` in the same directory as your `config.json`, which is most likely your `$GOPATH/bin` directory. You should see output similar to:
3. Run the Hound server with `houndd` in the same directory as your `config.json`. You should see output similar to:
```
2015/03/13 09:07:42 Searcher started for statsd
2015/03/13 09:07:42 Searcher started for Hound
Expand All @@ -62,21 +50,47 @@ the config found in [default-config.json](default-config.json):

4. By default, hound hosts a web ui at http://localhost:6080 . Open it in your browser, and start searching.

### Using Docker (1.4+)
### Using Docker (1.14+)

0. [Install docker](https://docs.docker.com/get-docker/) if you don't have it. We need at least `Docker >= 1.14`.

1. Create a config.json file and use it to list your repositories. Check out our [example-config.json](config-example.json)
to see how to set up various types of repositories. For example, we can configure Hound to search its own source code using
the config found in [default-config.json](default-config.json).

2. Run
```
docker run -d -p 6080:6080 --name hound -v $(pwd):/data ghcr.io/hound-search/hound:latest
```

#### Run with image from github

```
docker run -d -p 6080:6080 --name hound -v $(pwd):/data ghcr.io/hound-search/hound:latest
```

You should be able to navigate to [http://localhost:6080/](http://localhost:6080/) as usual.

#### Build image and container yourself

0. Clone repository
```
git clone https://github.com/hound-search/hound.git
cd hound
```

1. Build the image
```
docker build . --tag=hound
```

2. Create the container
```
docker create -p 6080:6080 --name hound -v $(pwd):/data hound
```

3. Starting and stopping the container
```
docker start hound
docker stop hound
```

## Running in Production

There are no special flags to run Hound in production. You can use the `--addr=:6880` flag to control the port to which the server binds.
Expand All @@ -88,7 +102,7 @@ We've used many similar tools in the past, and most of them are either too slow,
Which brings us to...

## Requirements
* Go 1.13+
* Go 1.16+

Yup, that's it. You can proxy requests to the Go service through Apache/nginx/etc., but that's not required.

Expand Down Expand Up @@ -134,9 +148,8 @@ Currently the following editors have plugins that support Hound:

#### Requirements:
* make
* Node.js ([Installation Instructions](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager))

While Hound is a proper go module that can be installed with `go install`, there is also a `Makefile` to aid in building locally.
* [npm](https://github.com/npm/cli/#installation)
(Usuall npm comes bundled with Node.js. If that's not the case on the system you're using, you can get it [here](https://nodejs.org/en/download))

```
git clone https://github.com/hound-search/hound.git
Expand Down Expand Up @@ -168,9 +181,8 @@ You need to install `Node.js >= 12` and install `jest` by `npm install jest` to

### Working on the web UI

Hound includes a web UI that is composed of several files (html, css, javascript, etc.). To make sure hound works seamlessly with the standard Go tools, these resources are all bundled inside of the `houndd` binary. Note that changes to the UI will result in local changes to the `ui/bindata.go` file. You must include these changes in your Pull Request.

To bundle UI changes in `ui/bindata.go` use:
Hound includes a web UI that is composed of several files (html, css, javascript, etc.).
To compile UI changes use:

```
make ui
Expand Down
2 changes: 1 addition & 1 deletion cmds/houndd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"syscall"

"github.com/blang/semver"
"github.com/blang/semver/v4"
"github.com/hound-search/hound/api"
"github.com/hound-search/hound/config"
"github.com/hound-search/hound/searcher"
Expand Down
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module github.com/hound-search/hound

go 1.13
go 1.16

require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
)
require github.com/blang/semver/v4 v4.0.0
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
github.com/blang/semver v1.1.0 h1:ol1rO7QQB5uy7umSNV7VAmLugfLRD+17sYJujRNYPhg=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/go-bindata/go-bindata v1.0.0 h1:DZ34txDXWn1DyWa+vQf7V9ANc2ILTtrEjtlsdJRF26M=
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
6 changes: 0 additions & 6 deletions tools/tools.go

This file was deleted.

Loading