gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
11.24k stars 624 forks source link

FreeBSD builds #199

Open geeseven opened 5 years ago

geeseven commented 5 years ago

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

eternal-flame-AD commented 5 years ago

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

jmattheis commented 5 years ago

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

eternal-flame-AD commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@geeseven Does the linux binary work on your machine?

geeseven commented 5 years ago

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 commented 5 years ago

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

geeseven commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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

barolo commented 5 years ago

@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 commented 4 years ago

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.

jmattheis commented 4 years ago

@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
jacquesh commented 4 years ago

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 commented 4 years ago

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 commented 2 years ago

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 commented 6 months ago

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)
lezruk commented 6 months ago

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

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
mfechner commented 2 days ago

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 commented 2 days ago

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.

mfechner commented 2 days ago

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.

jmattheis commented 2 days ago

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

mfechner commented 2 days ago

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 commented 2 days ago

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

mfechner commented 1 day ago

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 commented 1 day ago

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

jmattheis commented 1 day ago

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

mfechner commented 22 hours ago

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.