Open geeseven opened 5 years ago
@jmattheis What do you think? Should we add official support for this?
@eternal-flame-AD Sure, why not (:.
AFAIK Ubuntu does not seem to have a pre-built freebsd cross-compiler available. I think we need to build it from source manually. Right? @jmattheis
So, I'm not a free bsd user but I've you said that free bsd supports linux binary compatibility, why not use this instead?
Yeah, couldn't find a prebuilt cross compiler.
@geeseven Does the linux binary work on your machine?
Thanks for the timely replies. I was hoping to avoid Linux binary compatibility if possible. It seems like a workaround golang was designed to eliminate. That being said, I understand in the real world other issues crop up.
If there is no tooling and y'all do not use FreeBSD, I think official support more or less just providing 'as is' binaries is not a good idea. If/when I get time, I will report back how I got gotify running on FreeBSD.
I've recently deployed gotify on freeBSD based VPS without any issues, built without any hiccups. If that helps anybody
Hey @barolo, glad to hear. Do you mind sharing details on what you did, as I have not had a chance to look into this further.
Besides VPS specific stuff like setting paths [ it had to be compiled and installed in the user folder ] nothing much
go get -u github.com/gotify/server
in the ui folder:
npm install
npm run build
in the main folder
packr build
[ I had to get packr, but just:
go get -u github.com/gobuffalo/packr/packr
go get -u github.com/gobuffalo/packr
was enough ]
then copy config.example.yml into config.yml [ changed port to what I needed ] and launch serwer, done.
npm and go was already set up
@barolo, thanks for the details. Did the ports versions of go and npm not work? Also do you mind sharing your rc.d script?
@geeseven It's a VPS, I have no access to system or say in how it's set up, It was preconfigured by a hosting provider
Interesting, sounds more like a shell account than a VPS. None the less, thanks for sharing.
@geeseven It's something inbetween, on a shell account you can't usually binexec your own stuff. There's decent amount of configurability, myriad of dev tools of several versions and virtual environments for these [ It's also really cheap ]
I have been toying with sourcehut's build tools to see if it could be used for FreeBSD builds. They not only offer Linux build hosts, but also FreeBSD, OpenBSD and even 9front. :laughing:
I was able to get a build to complete, but I get the following error after coping the binary off the build host:
2020/06/06 15:51:47 [Recovery] 2020/06/06 - 15:51:47 panic recovered:
GET / HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: curl/7.70.0
stat /usr/home/user/ui/build/index.html: no such file or directory
Note, /health works, but /version gets weird:
$ curl localhost:8080/health
{"health":"green","database":"green"}
$ curl localhost:8080/version
{"version":"unknown","commit":"unknown","buildDate":"unknown"}
I will post updates if I make anymore progress.
@geeseven
Have a look at our build docs. Steps 2 and 3 are responsible for the ui: https://gotify.net/docs/build
The version info will be populated via ldflags: https://github.com/gotify/server/blob/92a468bf74f243c94f2c2a94db96247c962bef03/.travis.yml#L42
go build -ldflags="$LD_FLAGS" -o gotify-server
I don't use FreeBSD as my primary OS (so I'm not quite as clued up on it as I'd like to be) but I have a server that uses it and I'd like to run gotify on that.
I setup a new jail (to have a fresh environment of FreeBSD 11.4) and followed the documented build instructions. The instructions worked almost as-is without issue. I built gotify manually without docker or the makefile and only had to make two minor changes due to the default shell being csh rather than bash:
1) Instead of assigning LD_FLAGS as suggested, I set LDFLAGS with set LDFLAGS="-w -s -X main.Version=`git describe --tags | cut -c 2-` -X main.BuildDate=`date '+%F-%T'` -X main.Commit=`git rev-parse --verify HEAD` -X main.Mode=prod";
2) The build command similarly needs to change slightly to become: go build -ldflags="$LDFLAGS" -o gotify-server
I now appear have a fully-functioning gotify server running on FreeBSD. I'd be happy to help trying to roll that out to the Release/CI build process. I haven't tried yet but I expect if I installed bash and went through the build process there it'd work without modification.
Yeah, the problem is that there are no cross-compilers for freebsd. Thus, we cannot integrate this into the current build pipeline on travis-ci.
Restic (encrypted backup utility written in Go) provides FreeBSD builds. Maybe one of their pipelines can give some insight in how to solve this? https://github.com/restic/restic/blob/master/.github/workflows/tests.yml
Anyone has luck with recent build on Freebsd 14? I have currently yarn command run exception
bgotify ui (master?) # yarn
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "react-infinite > enzyme-adapter-react-16@1.1.1" has unmet peer dependency "enzyme@^3.0.0".
warning " > @typescript-eslint/eslint-plugin@4.33.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "@typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils@4.33.0" has unmet peer dependency "eslint@*".
warning "@typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils > eslint-utils@3.0.0" has unmet peer dependency "eslint@>=5".
warning " > @typescript-eslint/parser@4.33.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning " > eslint-config-prettier@6.15.0" has unmet peer dependency "eslint@>=3.14.1".
warning " > eslint-plugin-import@2.25.3" has unmet peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
warning " > eslint-plugin-jest@24.7.0" has unmet peer dependency "eslint@>=5".
warning " > eslint-plugin-prefer-arrow@1.2.3" has unmet peer dependency "eslint@>=2.0.0".
warning " > eslint-plugin-react@7.27.1" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
warning " > eslint-plugin-unicorn@21.0.0" has unmet peer dependency "eslint@>=7.3.0".
warning "eslint-plugin-unicorn > eslint-template-visitor@2.3.2" has unmet peer dependency "eslint@>=7.0.0".
warning "eslint-plugin-unicorn > eslint-template-visitor > @babel/eslint-parser@7.16.3" has unmet peer dependency "eslint@^7.5.0 || ^8.0.0".
[4/4] Building fresh packages...
[1/5] ⢀ puppeteer [-/5] ⢀ waiting...
[-/5] ⢀ waiting...
[4/5] ⢀ ejs
error /root/gotify/server/ui/node_modules/puppeteer: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /root/gotify/server/ui/node_modules/puppeteer
Output:
/root/gotify/server/ui/node_modules/puppeteer/lib/cjs/puppeteer/util/assert.js:28
throw new Error(message);
^
Error: Unsupported platform: freebsd
at assert (/root/gotify/server/ui/node_modules/puppeteer/lib/cjs/puppeteer/util/assert.js:28:15)
at new BrowserFetcher (/root/gotify/server/ui/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:216:44)
at PuppeteerNode.createBrowserFetcher (/root/gotify/server/ui/node_modules/puppeteer/lib/cjs/puppeteer/node/Puppeteer.js:208:16)
at downloadBrowser (/root/gotify/server/ui/node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:59:51)
Ignore above it was about puppeteer chromium download, can be skipped with env variable
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
I just wanted to create a package for FreeBSD and commit it into FreeBSD ports, but I see some problems.
The packages that are used for the UI (package.json) are outdated and do not work with nodejs (version 2017.0) which is the standard nodejs version available on FreeBSD, while I write this post.
It seems that at least react-scripts
needs to be updated to 5.0.1 and maybe some other packages.
I also see that eslint will maybe required some modifications as react-scripts
upgraded some dependencies.
Also the
"proxy": "http://localhost:80"
needs to be changed to:
"options": {
"proxy": "http://localhost:80"
},
But before I start with this, is there intereset to merge such modifications?
I the gotify-server repository will compile, I could start next to create a port for FreeBSD. There is not really a need to use all this docker stuff, as docker will only work with Linux. And go itself is no problem.
The is a arch build which works with the latest nodejs version, and also this repo uses node20 to build gotify/server. You are likely getting the error from this ticket https://github.com/gotify/server/issues/574, you can work around this by setting the env var https://github.com/gotify/server/issues/574#issuecomment-1614869901
Feel free to try updating to the latest react-scripts version, I've tried this a couple of hours but you have to update much more than just react-scripts.
Thanks @jmattheis, yes I think you are right. it will not only reacts-scripts that needs an update, but much more. The problem I currently see is that I get the error:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true NODE_OPTIONS=--openssl-legacy-provider yarn build
yarn run v1.22.22
$ react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
Failed to compile.
/usr/local/poudriere/ports/gitlab/net/gotify-server/work/github.com/gotify/server/v2@v2.5.0/ui/src/tests/authentication.ts
TypeScript error in /usr/local/poudriere/ports/gitlab/net/gotify-server/work/github.com/gotify/server/v2@v2.5.0/ui/src/tests/authentication.ts(1,20):
Cannot find module 'puppeteer' or its corresponding type declarations. TS2307
> 1 | import {Page} from 'puppeteer';
| ^
2 | import {waitForExists} from './utils';
3 | import * as selector from './selector';
4 |
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
So it seem that I must tell react-script to skip tests. I never did something with react. If someone has an idea, it is welcome, otherwise I need to read a little bit.
You can probably remove all files from ./ui/src/tests, they are not needed for the prod build.
Ok, I just patch the ui/tsconfig.json
to ignore the test.
I'm now able to generate a yarn offline cache file (FreeBSD does not allow network access while building).
Use the offline cache and build the UI.
Generate the go binary.
The next is now, that I must work a little bit on the configuration, but I think the hardest part is done.
The package is currently in POC mode, but compilation works now and a package is generated: https://pkg.fechner.net/data/141amd64-gitlab/2024-10-12_08h21m06s/logs/gotify-server-2.5.0.log
I will now start with testing and fine-tuning the package (this will maybe take most of the time ;) ).
Feel free to try updating to the latest react-scripts version, I've tried this a couple of hours but you have to update much more than just react-scripts.
I commited now a first version into the FreeBSD ports for gotify-server.
@jmattheis what do you think about switch from react-scripts to vite? I think it will be much faster the the amount of work is I think equal.
I support this, although the amount of work feels a lot to pull the whole front end to "modern ecosystem".
Yeah, vite seems to be the standard now, and react-scripts isn't maintained anymore.
ok, I have a first draft available. I will do some more tests, but at least on Windows it comiles and dev mode is also running. I will open a new issue with a pull request so it can be reviewed, but please give me some time.
Is your feature request related to a problem? Please describe. I would like to run gotify on FreeBSD but there are not any FreeBSD builds.
Describe the solution you'd like I would like to see FreeBSD builds for each release just like other OSes.
Describe alternatives you've considered Linux binary compatibility or running a Linux bhyve virtual machine are workarounds.
Additional context n/a