Comments (12)
I'll update the Makefile with two available building commands:
make all #builds all the projects, including the frontend project & the backend project make build # only build the backend project
I was working on it a bit: jlsalvador@0765d10
WIP. Take a look for improvements/ideas. 👍
A merge request will be submitted when it's completed.
from godns.
Thanks for the quick feedback, I've added one line of annotation at the beginning of the file internal/server/server.go
to copy the out
directory generated by the frontend project. So theoretically, you need to compile & build the frontend project first, and run go generate ./...
, it copies the out
directory to internal/server
.
Before doing that, you need to set up the frontend development environment first, please refer to: https://github.com/TimothyYe/godns?tab=readme-ov-file#setup-the-frontend-development-environment
I'll update the Makefile
in 3.1.1
release.
from godns.
I'm also seeing this in 3.1.2 or is the npm stuff a hard requirement now (please don't make it)?
===> Building for godns-3.1.2
(cd /usr/ports/dns/godns/work/godns-3.1.2; for t in ./cmd/godns; do out=$(/usr/bin/basename $(echo ${t} | /usr/bin/sed -Ee 's/^[^:]*:([^:]+).*$/\1/' -e 's/^\.$/godns/')); pkg=$(echo ${t} | /usr/bin/sed -Ee 's/^([^:]*).*$/\1/' -e 's/^godns$/./'); echo "===> Building ${out} from ${pkg}"; /usr/bin/env XDG_DATA_HOME=/usr/ports/dns/godns/work XDG_CONFIG_HOME=/usr/ports/dns/godns/work XDG_CACHE_HOME=/usr/ports/dns/godns/work/.cache HOME=/usr/ports/dns/godns/work PATH=/usr/ports/dns/godns/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/dns/godns/work/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe -march=tigerlake -fstack-protector-strong -fno-strict-aliasing " CPP="cpp" CPPFLAGS="" LDFLAGS=" -fstack-protector-strong " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -march=tigerlake -fstack-protector-strong -fno-strict-aliasing " BSD_INSTALL_PROGRAM="install -s -m 555" BSD_INSTALL_LIB="install -s -m 0644" BSD_INSTALL_SCRIPT="install -m 555" BSD_INSTALL_DATA="install -m 0644" BSD_INSTALL_MAN="install -m 444" CGO_ENABLED=1 CGO_CFLAGS="-I/usr/local/include" CGO_LDFLAGS="-L/usr/local/lib" GOAMD64= GOARM= GOTMPDIR="/usr/ports/dns/godns/work" GOPATH="/usr/ports/distfiles/go/dns_godns" GOBIN="/usr/ports/dns/godns/work/bin" GO111MODULE=on GOFLAGS=-modcacherw GOSUMDB=sum.golang.org GO_NO_VENDOR_CHECKS=1 GOMAXPROCS=6 GOPROXY=off /usr/local/bin/go120 build -buildmode=exe -v -trimpath -ldflags=-s -buildvcs=false -mod=vendor -o /usr/ports/dns/godns/work/bin/${out} ${pkg}; done)
===> Building godns from ./cmd/godns
internal/server/server.go:19:12: pattern out/*: no matching files found
*** Error code 1
from godns.
I'll update the Makefile with two available building commands:
make all #builds all the projects, including the frontend project & the backend project
make build # only build the backend project
from godns.
@diizzyy If you'd like to build it with your scripts, here is the workaround:
mkdir -p ./internal/server/out
touch ./internal/server/out/index.html
GO111MODULE=on go build cmd/godns/godns.go
from godns.
@TimothyYe
Thanks, it's actually for the FreeBSD port ( https://repology.org/project/godns/versions ) and that workaround seems to do the trick.
from godns.
@diizzyy Yes, it depends on whether you want to include the frontend project at compile time.
from godns.
There's a strict rule that no internet access is allowed during builds (which makes sense) however that makes npm more or less a no go (or a major pain I'm not willing to spend time on) so unless we can get a precompiled frontend there's not going to be packaged version with the frontend.
from godns.
@diizzyy Thanks for the explanation, however, I still have a bit of confusion. If there is no internet connection during builds, when compiling this Go project, if new modules are introduced in the code, they will also be downloaded from the internet during the compilation period. How is this achieved?
from godns.
By build I guess I should say compilation as packaging is divided into different stages ( https://docs.freebsd.org/en/books/porters-handbook/book/#options-targets ).
See also:
https://docs.freebsd.org/en/books/porters-handbook/book/#using-go
https://cgit.freebsd.org/ports/tree/Mk/Uses/go.mk
from godns.
@diizzyy I asked ChatGPT for an example of a Makefile to build the port, which includes npm and Go as dependencies. I'm not sure if it will be helpful:
# Ports metadata
PORTNAME= myproject
DISTVERSION= 1.0.0
CATEGORIES= www
MAINTAINER= [email protected]
COMMENT= An example Go project with embedded Next.js static files
LICENSE= MIT
BUILD_DEPENDS= npm:www/npm \
go:lang/go
USES= go:modules
# Use the post-extract target to install Node.js dependencies and build the Next.js project
post-extract:
@cd ${WRKSRC}/web && ${SETENV} ${MAKE_ENV} npm install
@cd ${WRKSRC}/web && ${SETENV} ${MAKE_ENV} npm run build
# Use the pre-build target to move the Next.js build output to the location expected by the Go code
pre-build:
@${MKDIR} ${WRKSRC}/internal/server
@${MV} ${WRKSRC}/web/out/* ${WRKSRC}/internal/server
# Use the do-build target to build the Go project, embedding the Next.js static files
do-build:
@cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} go build -o ${PORTNAME} cmd/${PORTNAME}/main.go
# Use the do-install target to install the built Go binary
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
.include <bsd.port.mk>
Key Points:
-
BUILD_DEPENDS: This line declares build-time dependencies for your port, including npm for building the Next.js project and go for compiling the Go project.
-
USES: This directive specifies that the port uses Go modules for managing Go dependencies.
-
post-extract: This target is run after extracting your port's distfiles but before building. It's used here to install Node.js dependencies and build the Next.js project. Adjust the paths according to your project's structure.
from godns.
npm is more complicated than that (which is why you rarely see it packaged in any repo).
See below for example
https://cgit.freebsd.org/ports/tree/textproc/write-good/Makefile
https://cgit.freebsd.org/ports/tree/www/py-django-hijack/Makefile
from godns.
Related Issues (20)
- Feature request: Support OVH provider HOT 2
- 配置了这个DDNS服务后,怎么配置端口做转发呢? HOT 1
- Prebuilt binary for OpenBSD, please. This rc syntax should suffice for creation of an rc file to run with rc.d. HOT 9
- Deleting published tags is a bad idea HOT 1
- Usage of ip_urls should use round-robin HOT 2
- yaml config file support in docker? HOT 2
- Fails to determine IP address of Interface on FreeBSD HOT 11
- 同时更新IPv4和IPv6的配置文件怎么写呀? HOT 6
- how to hidden cmd window in widnows HOT 3
- dynu supoort? HOT 2
- No timeout when getting ip with http client HOT 2
- 网络访问失败时需要添加延时再重试 目前连续访问会导致CPU占用100% HOT 2
- 优化建议:支持从本地网口直接获取IP HOT 1
- 想用网卡的IP地址报错 HOT 1
- PowerDNS, DynDNS(2) or RFC2136?
- The strangest thing (wrong public IP) HOT 3
- Docker Image not updating public ip address as per interval configuration HOT 3
- 能否做一下myip.la的API适配 HOT 9
- Add a way to query IP address through a specific interface HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godns.