Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD builds #199

Open
geeseven opened this issue Jun 15, 2019 · 31 comments
Open

FreeBSD builds #199

geeseven opened this issue Jun 15, 2019 · 31 comments
Labels
a:feature New feature or request

Comments

@geeseven
Copy link

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

@geeseven geeseven added the a:feature New feature or request label Jun 15, 2019
@eternal-flame-AD
Copy link
Member

@jmattheis What do you think? Should we add official support for this?

@jmattheis
Copy link
Member

@eternal-flame-AD Sure, why not (:.

@eternal-flame-AD
Copy link
Member

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

@jmattheis
Copy link
Member

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.

@eternal-flame-AD
Copy link
Member

@geeseven Does the linux binary work on your machine?

@geeseven
Copy link
Author

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.

@barolo
Copy link

barolo commented Jul 12, 2019

I've recently deployed gotify on freeBSD based VPS without any issues, built without any hiccups. If that helps anybody

@geeseven
Copy link
Author

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.

@barolo
Copy link

barolo commented Jul 12, 2019

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

@geeseven
Copy link
Author

@barolo, thanks for the details. Did the ports versions of go and npm not work? Also do you mind sharing your rc.d script?

@barolo
Copy link

barolo commented Jul 12, 2019

@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

@geeseven
Copy link
Author

Interesting, sounds more like a shell account than a VPS. None the less, thanks for sharing.

@barolo
Copy link

barolo commented Jul 12, 2019

@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 ]

@geeseven
Copy link
Author

geeseven commented Jun 6, 2020

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. 😆

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.

@jmattheis
Copy link
Member

@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:

export LD_FLAGS="-w -s -X main.Version=${VERSION} -X main.BuildDate=$(date "+%F-%T") -X main.Commit=$(git rev-parse --verify HEAD) -X main.Mode=prod";

go build -ldflags="$LD_FLAGS" -o gotify-server

@jacquesh
Copy link

jacquesh commented Jul 24, 2020

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.

@jmattheis
Copy link
Member

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.

@peterrus
Copy link

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

@lezruk
Copy link

lezruk commented Apr 10, 2024

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 > [email protected]" has unmet peer dependency "enzyme@^3.0.0".
warning " > @typescript-eslint/[email protected]" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "@typescript-eslint/eslint-plugin > @typescript-eslint/[email protected]" has unmet peer dependency "eslint@*".
warning "@typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils > [email protected]" has unmet peer dependency "eslint@>=5".
warning " > @typescript-eslint/[email protected]" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning " > [email protected]" has unmet peer dependency "eslint@>=3.14.1".
warning " > [email protected]" has unmet peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
warning " > [email protected]" has unmet peer dependency "eslint@>=5".
warning " > [email protected]" has unmet peer dependency "eslint@>=2.0.0".
warning " > [email protected]" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
warning " > [email protected]" has unmet peer dependency "eslint@>=7.3.0".
warning "eslint-plugin-unicorn > [email protected]" has unmet peer dependency "eslint@>=7.0.0".
warning "eslint-plugin-unicorn > eslint-template-visitor > @babel/[email protected]" 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)

@lezruk
Copy link

lezruk commented Apr 10, 2024

Ignore above it was about puppeteer chromium download, can be skipped with env variable

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

@mfechner
Copy link

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.

@jmattheis
Copy link
Member

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 #574, you can work around this by setting the env var #574 (comment)

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.

@mfechner
Copy link

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/[email protected]/ui/src/tests/authentication.ts
TypeScript error in /usr/local/poudriere/ports/gitlab/net/gotify-server/work/github.com/gotify/server/[email protected]/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.

@jmattheis
Copy link
Member

You can probably remove all files from ./ui/src/tests, they are not needed for the prod build.

@mfechner
Copy link

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.

@mfechner
Copy link

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 ;) ).

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Oct 13, 2024
A simple selfhosted message service with nice UI and a client for
Android.

Thanks a lot for help I received here:
gotify/server#199
@mfechner
Copy link

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.

@eternal-flame-AD
Copy link
Member

I support this, although the amount of work feels a lot to pull the whole front end to "modern ecosystem".

@jmattheis
Copy link
Member

Yeah, vite seems to be the standard now, and react-scripts isn't maintained anymore.

@mfechner
Copy link

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.

@mfechner
Copy link

I just push gotify-cli as a port to the FreeBSD ports, so there is now also a package for this very soon available.

I think we have a a good start point to work on all the other topics.

I created already here an issue for the react-scripts migration:
#695

And here is a draft PR (will need some more work, but is a good start):
#696
The tests fail, but this is just executing the testing, the migration itself should be more or less completed.

If the migration to vite is done, we can also close this issue:
#574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature New feature or request
Development

No branches or pull requests

8 participants