Skip to content
Open
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
11 changes: 11 additions & 0 deletions .fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-s dir
--name netgate
--category net
--license MIT
--description "An inbound network gateway with authentication, proxy, and management UI."
--url "https://github.com/mrhaoxx/OpenNG"
--maintainer "mrhaoxx <mr.haoxx@gmail.com>"
--config-files /etc/netgate/config.yaml
doc/config-sample.yaml=/etc/netgate/config.yaml
netgate.service=/usr/lib/systemd/system/netgate.service
netgate=/usr/bin/netgate
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ new.config.yaml

**dist**
node_modules
.claude
.claude
/netgate
*.deb
DEBIAN/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y build-essential git
COPY . /go/src/github.com/mrhaoxx/OpenNG
COPY --from=web /workdir/dist /go/src/github.com/mrhaoxx/OpenNG/ui/html/dist

RUN cd /go/src/github.com/mrhaoxx/OpenNG && ./build.sh -o /NetGATE
RUN cd /go/src/github.com/mrhaoxx/OpenNG && make NAME=/NetGATE

FROM debian:bookworm AS runtime

Expand Down
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
NAME=netgate
BUILDTIME=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
VERSION ?= $(shell v="$$(git describe --tags --abbrev=7 --dirty 2>/dev/null)"; \
echo "$${v:-0.0.0}" | sed 's/^v//; s/-/./g')

GOBUILD=go build -a \
-ldflags "-w -s \
-X 'main.buildstamp=$(BUILDTIME)' \
-X 'main.gitver=$(VERSION)'"

HOST_ARCH=$(shell uname -m)
ifeq ($(HOST_ARCH),x86_64)
HOST_GOARCH=amd64
else ifeq ($(HOST_ARCH),aarch64)
HOST_GOARCH=arm64
else
HOST_GOARCH=$(HOST_ARCH)
endif

ui:
(cd ui/html && npm install && npm run build)

linux-amd64:
GOOS=linux GOARCH=amd64 GOAMD64=v2 $(GOBUILD) -o $(NAME)

linux-arm64:
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(NAME)

all: linux-$(HOST_GOARCH)

deb: deb-$(HOST_GOARCH)

deb-amd64: linux-amd64 ui
fpm -t deb -v "$(VERSION)" -p "$(NAME)_$(VERSION)_amd64.deb" --architecture amd64 -f

deb-arm64: linux-arm64 ui
fpm -t deb -v "$(VERSION)" -p "$(NAME)_$(VERSION)_arm64.deb" --architecture arm64 -f

clean:
rm -f $(NAME) *.deb

.PHONY: all ui linux-amd64 linux-arm64 deb deb-amd64 deb-arm64 clean
15 changes: 0 additions & 15 deletions build.sh

This file was deleted.

20 changes: 11 additions & 9 deletions netgate.service
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[Unit]

[Install]
WantedBy=multi-user.target
Description=Netgate - Inbound Network Gateway
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/home/ubuntu/OpenNG
WorkingDirectory=/home/ubuntu/OpenNG
User=ubuntu
# Runs as root: needs access to TLS certificates owned by root
Type=simple
ExecStart=/usr/bin/netgate -config /etc/netgate/config.yaml
WorkingDirectory=/etc/netgate
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target