Skip to content

Commit

Permalink
refactor(wg-api): move main package to root for easier builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescun committed Oct 7, 2022
1 parent 3d16909 commit 3b04a5c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.17 AS builder
FROM golang:1.19 AS builder

WORKDIR /go/src/github.com/jamescun/wg-api
COPY . /go/src/github.com/jamescun/wg-api

RUN CGO_ENABLED=0 GOOS=linux go build -o wg-api cmd/wg-api.go
RUN CGO_ENABLED=0 GOOS=linux go build -o wg-api main.go


FROM scratch
COPY --from=builder /go/src/github.com/jamescun/wg-api/wg-api /bin/wg-api
CMD ["wg-api"]
COPY --from=builder /go/src/github.com/jamescun/wg-api/wg-api /wg-api
ENTRYPOINT ["/wg-api"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Binaries for Linux are available [here](https://github.com/jamescun/wg-api/relea

### Build Yourself

WG-API requires at least Go 1.13.
WG-API requires at least Go 1.17.

```sh
go install github.com/jamescun/wg-api/cmd
go install github.com/jamescun/wg-api
```

This should install the server binary `wg-api` in your $GOPATH/bin.
Expand Down
6 changes: 3 additions & 3 deletions cmd/wg-api.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"strings"

wireguardapi "github.com/jamescun/wg-api"
"github.com/jamescun/wg-api/server"
"github.com/jamescun/wg-api/server/jsonrpc"

Expand Down Expand Up @@ -48,6 +47,8 @@ Warnings:
Additionally authentication tokens should be configured.
`

var Version = "1.0.0"

var (
// helpers
listDevices = flag.Bool("list-devices", false, "")
Expand Down Expand Up @@ -88,7 +89,7 @@ func main() {
}

case *showVersion:
fmt.Println("WG-API Version:", wireguardapi.Version)
fmt.Println("WG-API Version:", Version)

default:
client, err := wgctrl.New()
Expand Down Expand Up @@ -155,7 +156,6 @@ func main() {
}
}
}

}

func exitError(format string, args ...interface{}) {
Expand Down
3 changes: 0 additions & 3 deletions version.go

This file was deleted.

0 comments on commit 3b04a5c

Please sign in to comment.