jflamy / owlcms4

Olympic Weightlifting Competition Management System
https://owlcms.github.io/owlcms4/#/index
Other
63 stars 20 forks source link

Docker Image #488

Closed JDFS404 closed 2 years ago

JDFS404 commented 2 years ago

We're using this software in The Netherlands for a lot of meets. Is there a possibility to install this on a Docker image on our own server and host the database ourselves?

jflamy-dev commented 2 years ago

See https://hub.docker.com/r/owlcms/owlcms/tags stable is the latest release prerelease is the latest prerelease.

For the database, you should not use the default which is to use a local H2 file located in ./database because you would lose on on container restart. You probably want to use a Postgres container with suitable external persistent storage, or a local Postgres install, and connect your container to that. The environment variables you would need to provide are listed in https://owlcms.github.io/owlcms4-prerelease/#/PostgreSQL

JDFS404 commented 2 years ago

Wow! Totally missed that. Couple of questions:

I'm already planning on using this behind a reverse proxy/CloudFlare to only use the IP of the venue which we are using in The Netherlands (I'm involved since a couple of weeks with the WL federation here and we're already using this on Heroku. Since I have my own server I can do more with it and I have some reverse proxy experience).

The system works great btw! We're using Bluetooth buttons that connect to an iPad to give good/no lift. Next step is using my MQTT server perhaps with some ESP32/Wemos devices. But I need to think about how to utilize that.

Edit: I have it up and running now, filled in all environment variables, only to find out some of them I can edit from within OWLCMS 😂.

For those of you interested in running this on something else than PostgreSQL, i.e. MariaDB, use the following variable: jdbc:mariadb://localhost:3306/db

jflamy-dev commented 2 years ago

1) Only Postgres is tested at this time . 2) The Heroku install I support with the "one-click button" does not use Docker because Heroku one-click works in conjunction with Git. It deploys as a Java application, and connects to an Heroku-supplied Postgres. The list of variables is indeed the list of configuration variables for OWLCMS itself. The JDBC_ variables listed in the Postgres file are the same that Heroku provides when launching an application . 3) The instructions for translating are https://owlcms.github.io/owlcms4-prerelease/#/Translation . 4) No. The program is NOT setup to have horizontal scaling (multiple containers), and making it work like that is simply not needed. The program has a very small footprint actually. The issue with Heroku free is that there is no control over who else shares the resources with you, and the memory limits are just a little bit tight. Upgrading to the first paid tier is good enough to get 1024MB .

JDFS404 commented 2 years ago

Woops, mariadb/mySQL are not working... I'm back to PostgreSQL but this is the log I receive: Database: jdbc:h2:file:/database/owlcms-h2v2;DB_CLOSE_DELAY=-1;TRACE_LEVEL_FILE=4, inMemory=false, schema=update [app.owlcms.Main:329 h2FileProperties]

Doesn't look like it's using PostgreSQL right?

jflamy-dev commented 2 years ago

Clearly not.

There are two ways to get owlcms to use Postgres.

One is to set the variable JDBC_DATABASE_URL to something that starts with jdbc:postgres and set JDBC_DATABASE_USERNAME and JDBC_DATABASE_PASSWORD to the correct value. In this case the port number and host are in the URL.

The other way is to NOT set JDBC_DATABASE_URL at all. Instead, use the five variables POSTGRES_HOST POSTGRES_PORT POSTGRES_DB POSTGRES_USER and POSTGRES_PASSWORD

Both should work (Heroku uses the first method, and under Kubernetes the owlcms container talks to the postgres container using the second method).

jflamy-dev commented 2 years ago

Obviously, the host name you provide in the url or in POSTGRES_HOST must be understood from inside the docker container where owlcms runs. Where/how are you running the container(s) ? I've only run the containers directly for debugging or within Kubernetes, so I'm not sure I can help you much more.

jflamy-dev commented 2 years ago

A successful owlcms start with postgres looks like the following...

17:45:39.365 INFO  owlcms 4.32.0-rc02 built 2022-06-02 18:02:17 (America/Montreal)             [app.owlcms.Main:128 logStart]
17:45:39.409 INFO  starting web server                                                         [app.owlcms.Main:94 run]
17:45:39.564 INFO  Database: jdbc:postgresql://10.43.217.33:5432/owlcms_db, schema=update      [app.owlcms.Main:410 pgProperties]
JDFS404 commented 2 years ago

Never mind, I followed the env variables according to the Github.io page and put in djdbc_database_url but it should be minus the D. Is that only the case for Kubernetes/Heroku?

Btw, I've got it up and running now, forwarded the public results to domain.nl and will deploy all competitions to subdomain.domain.nl. I have an Authelia 2FA which I can put before the log-in, or just use certain external IPs. It's running via CloudFlare, so end-to-end secured :)

Great work you've put in here!

This is what I'm getting now in my logs:


20:20:32.999 INFO  starting web server                                                         [app.owlcms.Main:94 run]
20:20:33.465 INFO  Database: jdbc:postgresql://192.168.1.159:5432/owlcmsdb, schema=update      [app.owlcms.Main:410 pgProperties]
20:20:46.598 INFO  started on port 8080                                                        [app.owlcms.Main:131 run]
20:20:46.814 INFO  no override directory /local                                                [app.owlcms.utils.ResourceWalker:69 checkForLocalOverrideDirectory]
20:20:47.635 INFO  forcing display language to                                                 [app.owlcms.Main:247 overrideDisplayLanguage]
20:20:47.651 INFO  injecting initial data EMPTY_COMPETITION                                    [app.owlcms.Main:173 injectData]
20:20:49.603 INFO  loading configuration file /agegroups/AgeGroups.xlsx                        [app.owlcms.data.agegroup.AgeGroupRepository:228 doInsertAgeGroup]
20:20:53.155 INFO  FOP A    Pushing results to remote site not enabled.                        [app.owlcms.uievents.EventForwarder:123 <init>]
20:20:53.163 INFO  FOP A    no clock owner [(FieldOfPlay.java:832)]                            [app.owlcms.fieldofplay.FieldOfPlay:1657 setClockOwner]
20:20:53.164 INFO  FOP A    entering INACTIVE (OwlcmsFactory.java:119)                         [app.owlcms.fieldofplay.FieldOfPlay:1206 setState]
20:20:53.166 INFO  initialization done, allowing requests.                                     [app.owlcms.Main:137 run]
20:20:53.804 WARN  Cannot start browser on Linux                                               [app.owlcms.utils.StartupUtils:191 startBrowser]```
JDFS404 commented 2 years ago

Is it possible to allow a backdoor IP in the form of a subdomain? I.e. backdoor.domain.nl instead of something like 192.168.1.x?

jflamy-dev commented 2 years ago

-D is the Java flag to Define an environment variable.

jflamy-dev commented 2 years ago

Short answer is no. Longer answer is that when I get the request, I have to figure out where the request is coming from using the HTTP headers. And the header vary depending on whether or not the request came through a reverse proxy (which is usually the case if hosted in the cloud or on a provider). So what I see is the public address of the router from which you entered the internet. You probably want that to be a unique address anyway, given what it allows you to do.

jflamy-dev commented 2 years ago

I will look into Authelia. Might enable something less crude.