update makefile and documentation (#74)

This commit is contained in:
Markus Viitamäki
2020-06-09 13:13:53 +02:00
committed by GitHub
parent bdf5423ad3
commit 558616a87c
4 changed files with 77 additions and 42 deletions
+5 -8
View File
@@ -45,19 +45,16 @@ jobs:
- name: npm install & build - name: npm install & build
run: | run: |
npm install --prefix ui make ui
npm run --prefix ui build
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: '1.14' go-version: '1.14'
- name: Fetch Go dependencies - name: Insert assets into go
run: | run: |
go get -u github.com/go-bindata/go-bindata/... make assets
go get github.com/elazarl/go-bindata-assetfs/...
go-bindata-assetfs -prefix ui/dist ui/dist
- name: Build wg-ui for Linux (AMD64) - name: Build wg-ui for Linux (AMD64)
run: | run: |
@@ -66,7 +63,7 @@ jobs:
target=linux-amd64 target=linux-amd64
release_name="$name-$tag-$target" release_name="$name-$tag-$target"
release_tar="$release_name.tar.gz" release_tar="$release_name.tar.gz"
env CGO_ENABLED=0 go build -o "$release_name" env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "$release_name"
tar czvf "$release_tar" "$release_name" tar czvf "$release_tar" "$release_name"
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256"
rm "$release_name" rm "$release_name"
@@ -114,7 +111,7 @@ jobs:
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get -qq -y install buildah sudo apt-get -qq -y install buildah
- name: Build & push wg-ui Docker image - name: Build & push wg-ui to docker hub
env: env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
+5 -5
View File
@@ -5,17 +5,17 @@ RUN npm install
COPY ui . COPY ui .
RUN npm run build RUN npm run build
FROM docker.io/golang:1.13 AS build FROM docker.io/golang:1.14 AS build
WORKDIR /wg WORKDIR /wg
RUN go get github.com/go-bindata/go-bindata/... &&\ RUN go get github.com/go-bindata/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/... RUN go get github.com/elazarl/go-bindata-assetfs/...
COPY go.mod . COPY go.mod .
COPY go.sum . COPY go.sum .
RUN go mod download RUN go mod download
COPY . . COPY . .
COPY --from=ui /ui/dist ui/dist COPY --from=ui /ui/dist ui/dist
RUN go-bindata-assetfs -prefix ui/dist ui/dist &&\ RUN go-bindata-assetfs -prefix ui/dist ui/dist
go install . RUN go install .
FROM gcr.io/distroless/base FROM gcr.io/distroless/base
COPY --from=build /go/bin/wireguard-ui / COPY --from=build /go/bin/wireguard-ui /
+36 -8
View File
@@ -1,19 +1,47 @@
.PHONY: binary container ui # Parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOGET=$(GOCMD) get
BINARY_NAME=wireguard-ui
binary: go-binary ui .PHONY: build container ui assets
go-binary: all: build
go-bindata-assetfs -prefix ui/dist ui/dist
go build . clean:
$(GOCLEAN)
rm -rf bin
rm -rf ui/node_modules ui/dist
ui: ui:
cd ui && npm install && npm run build cd ui && npm install && npm run build
assets:
$(GOGET) github.com/go-bindata/go-bindata/...
$(GOGET) github.com/elazarl/go-bindata-assetfs/...
go-bindata-assetfs -prefix ui/dist ui/dist
build: ui assets
CGO_ENABLED=0 $(GOBUILD) -o bin/$(BINARY_NAME) -v
build-amd64: ui assets
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o bin/$(BINARY_NAME)-amd64 -v
build-armv5: ui assets
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 $(GOBUILD) -o bin/$(BINARY_NAME)-armv5 -v
build-armv6: ui assets
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -o bin/$(BINARY_NAME)-armv6 -v
build-armv7: ui assets
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD) -o bin/$(BINARY_NAME)-armv7 -v
container: container:
docker build -t wireguard-ui . docker build -t wireguard-ui .
run-dev: go-binary run-dev:
sudo ./wireguard-ui --log-level=debug --dev-ui-server=http://localhost:5000 sudo ./bin/$(BINARY_NAME) --log-level=debug --dev-ui-server=http://localhost:5000
run-dev-ui: ui run-dev-ui:
cd ui && npm run dev cd ui && npm run dev
+31 -21
View File
@@ -1,6 +1,6 @@
# WireGuard UI # WireGuard UI
[![Build Status](https://github.com/embarkstudios/wg-ui/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/EmbarkStudios/wg-ui/actions) [![Build Status](https://github.com/EmbarkStudios/wg-ui/workflows/Build%20&%20Release/badge.svg?branch=master)](https://github.com/EmbarkStudios/wg-ui/actions)
[![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://github.com/EmbarkStudios) [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://github.com/EmbarkStudios)
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
@@ -13,7 +13,7 @@ Current stable release: [v1.1.0](https://github.com/EmbarkStudios/wg-ui/releases
* QR-Code for convenient mobile client configuration * QR-Code for convenient mobile client configuration
* Optional multi-user support behind an authenticating proxy * Optional multi-user support behind an authenticating proxy
* Zero external dependencies - just a single binary using the wireguard kernel module * Zero external dependencies - just a single binary using the wireguard kernel module
* Container-first deployment * Binary and container deployment
![Screenshot](wireguard-ui.png) ![Screenshot](wireguard-ui.png)
@@ -80,24 +80,36 @@ curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
git clone https://github.com/EmbarkStudios/wg-ui.git && cd wg-ui git clone https://github.com/EmbarkStudios/wg-ui.git && cd wg-ui
``` ```
### Build frontend ### Build binary with ui
```
make build
```
### Crosscompiling
```
make build-amd64
```
```
make build-armv5
```
```
make build-armv6
```
```
make build-armv7
```
### Build step by step
``` ```
make ui make ui
``` make assets
make build
### Build Go binary
```
go get -u github.com/go-bindata/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/...
make go-binary
```
### Build Go binary for ARM
```
env GOOS=linux GOARCH=arm GOARM=5 go build .
``` ```
## Developing ## Developing
@@ -111,10 +123,8 @@ npm run --prefix=ui dev
### Use frontend server when running the server ### Use frontend server when running the server
``` ```
go get -u github.com/go-bindata/go-bindata/... make build
go get github.com/elazarl/go-bindata-assetfs/... sudo ./bin/wireguard-ui --log-level=debug --dev-ui-server http://localhost:5000
make go-binary
sudo ./wireguard-ui --log-level=debug --dev-ui-server http://localhost:5000
``` ```
## Contributing ## Contributing