Crissium/SilverDict

trying to install silverdict on a debian lxc

Closed this issue ยท 24 comments

hi there,
i did yarnpkg build , but there is no "http_server" to move

i got this :


(sd) root@lxcSilDict:/home/SilverDict/client# yarnpkg build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
One of your dependencies, babel-preset-react-app, is importing the
"@babel/plugin-proposal-private-property-in-object" package without
declaring it in its dependencies. This is currently working because
"@babel/plugin-proposal-private-property-in-object" is already in your
node_modules folder for unrelated reasons, but it may break at any time.

babel-preset-react-app is part of the create-react-app project, which
is not maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
your devDependencies to work around this error. This will make this message
go away.

Compiled with warnings.

[eslint]
src/DesktopApp.js
  Line 96:5:   React Hook useEffect has missing dependencies: 'query' and 'search'. Either include them or remove the dependency array                                             react-hooks/exhaustive-deps
  Line 128:5:  React Hook useEffect has missing dependencies: 'latestSuggestionsTimestamp' and 'resetDictionariesHavingQuery'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

src/MobileApp.js
  Line 102:5:  React Hook useEffect has missing dependencies: 'query' and 'search'. Either include them or remove the dependency array                                             react-hooks/exhaustive-deps
  Line 128:5:  React Hook useEffect has missing dependencies: 'latestSuggestionsTimestamp' and 'resetDictionariesHavingQuery'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

src/components/Article.js
  Line 50:5:  React Hook useEffect has missing dependencies: 'isMobile' and 'setQuery'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  60.89 kB  build/static/js/main.88278f2a.js
  744 B     build/static/css/main.76883690.css
  658 B     build/static/css/319.e3dc2fa1.chunk.css
  533 B     build/static/css/607.7065f111.chunk.css
  164 B     build/static/js/607.1b6d42e2.chunk.js
  163 B     build/static/js/319.f9ef5ac5.chunk.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

Done in 15.22s.
(sd) root@lxcSilDict:/home/SilverDict/client# ll
total 512
drwxr-xr-x   6 root root   4096 Oct 11 18:27 ./
drwxr-xr-x   7 root root   4096 Oct 11 18:26 ../
-rw-r--r--   1 root root   3352 Oct 11 18:26 README.md
drwxr-xr-x   3 root root   4096 Oct 11 18:27 build/
drwxr-xr-x 844 root root  36864 Oct 11 18:27 node_modules/
-rw-r--r--   1 root root    840 Oct 11 18:26 package.json
drwxr-xr-x   2 root root   4096 Oct 11 18:26 public/
drwxr-xr-x   3 root root   4096 Oct 11 18:26 src/
-rw-r--r--   1 root root 450978 Oct 11 18:26 yarn.lock
(sd) root@lxcSilDict:/home/SilverDict/client#

Hello. There is a directory http_server in the top level directory. So please move your generated build directory there.

mv client/build http_server # in the project directory

Hello. There is a directory http_server in the top level directory. So please move your generated build directory there.

mv client/build http_server # in the project directory

thank you for your answer.

Should i run python3 http-server.py and python3 server.py inside tmux or nohup sessions?

Should i run python3 http-server.py and python3 server.py inside tmux or nohup sessions?

I haven't used LXCs and don't quite understand why you have to use nohup or something similar. Is it possible to set up systemd units?

If not, then perhaps nohup is the best solution for keeping a server process alive.

And I do recommend using nginx/apache as the HTTP server instead of my primitive script http_server.py.

I have no idea how to use nginx or apache :(
I could finally manage to run these two python script in two separate tmux sessions and now is the silverdict up. Where should i store my dictionaries in order to index them via silverdict?

The default source directory where your dictionaries are kept and could be automatically indexed is ~/.silverdict/source. Does LXC support volume mapping (like docker)? Then you can map the source directory on the host to the one inside the container.

Actually I do not recommend docker or any other container technology. It has caused me much pain and woe to get all the dictionaries files inside the container. A python environment should be enough.

After putting your dictionaries in the right place, open the web interface, click on the settings icon, and you will see a list of sources enabled. Click on the rescan button and wait for the dictionary list to update. Then you can give the dictionaries some nice aliases and group them.

Thank you for your answer.

I don't have much experience but in the last year, since I built my homelab and got to know docker, I had no problem with mapping volumes inside docker containers, especially when it should be mapped read-only. (because of permissions)

lxc containers are more like VMs and you can theoretically mount a SMB server

Thank you for your information on containers. I don't know much about them, so can offer little assistance in this respect. But if you run into any problems, do let me know, I'll try to help

As for permissions, does a SMB server support writes? During indexing the server has to write to the embedded sqlite database and DSL files are preprocessed.

when you create a smb server you can define if read allowed is and when you're mounting them you can mount them ro if you want.
by the way I have seen a lot of web apps as docker-compse, which have a DB container (maria DB for instance)

here is wallabag docker-compose as an example from my portainer stacks

version: '3'
services:
  wallabag:
    image: wallabag/wallabag
    environment:
      - MYSQL_ROOT_PASSWORD=xxxxxxxxxxxxxxxxxxx
      - SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
      - SYMFONY__ENV__DATABASE_HOST=db
      - SYMFONY__ENV__DATABASE_PORT=3306
      - SYMFONY__ENV__DATABASE_NAME=wallabag
      - SYMFONY__ENV__DATABASE_USER=wallabag
      - SYMFONY__ENV__DATABASE_PASSWORD=xxxxxxxxxxxxxxxxxxx
      - SYMFONY__ENV__DATABASE_CHARSET=utf8mb4
      - SYMFONY__ENV__DATABASE_TABLE_PREFIX="wallabag_"
      #- SYMFONY__ENV__MAILER_DSN=smtp://127.0.0.1
      #- SYMFONY__ENV__FROM_EMAIL=wallabag@example.com 
      #docker exec -ti $Container_ID /var/www/wallabag/bin/console --env=prod fos:user:change-password
      #- SYMFONY__ENV__DOMAIN_NAME=
      - SYMFONY__ENV__SERVER_NAME="My wallabag instance"
    ports:
      - 8044:80
    volumes:
      - images:/var/www/wallabag/web/assets/images
    healthcheck:
      test: ["CMD", "wget" ,"--no-verbose", "--tries=1", "--spider", "http://localhost"]
      interval: 1m
      timeout: 3s
    depends_on:
      - db
      - redis
    restart: unless-stopped
  db:
    image: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=xxxxxxxxxxxxxxxxxxx
    volumes:
      - db:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      interval: 20s
      timeout: 10s
    restart: unless-stopped
  redis:
    image: redis:alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 20s
      timeout: 3s
    restart: unless-stopped
volumes:
  images:
  db:

I see. So did you set up your silverdict instance inside the lxc? Good luck with it. I am sorry for the scant documentation available and will write some detailed guides later.

And I cannot use a 'real' database such as mariadb, because it would be too big a dependency and consume an undue amount of memory.

Everything persistent is inside ~/.silverdict (configurations and data) and ~/.cache/SilverDict (extracted resources files, primarily multimedia). So I think if you mount them somehow inside the lxc, things will work smoothly.

The demo server is actually also a docker-compose. I first set everything up with a local SilverDict instance, the running mode configured to 'preparation' to extract all resource file. Then I moved the python backend, the web app's static files and the data files together and defined appropriate volumes. After that I built the docker image (with the dictionaries inside) and deployed it to Okteto.

How's it going? Sorry to bump the issue, but I just added better support for RTL languages. Could you please try it out and tell me how you like it?

How's it going? Sorry to bump the issue, but I just added better support for RTL languages. Could you please try it out and tell me how you like it?

Thank you for taking the time to make sure that RTL languages are shown properly.
I have put an English-Farsi dictionary in both MDICT format and Stardict in the ~/.silverdict/source folder. But when I click on rescan source I get this error message.

image

root@lxcSilverDict:~/.silverdict/source# ll
total 57664
drwxr-xr-x 2 root root     4096 Oct 14 18:27  ./
drwxr-xr-x 3 root root     4096 Oct 12 09:28  ../
-rw-r--r-- 1 root root     1887 Oct 14 18:12  AD.css
-rw-r--r-- 1 root root 11012719 Oct 14 18:12 'Aryanpour Dictionary.mdx'
-rw-r--r-- 1 root root   310636 Oct 14 18:12 'Aryanpour Dictionary.png'
-rw-r--r-- 1 root root 42230945 Feb 11  2021  Aryanpur.dict
-rw-r--r-- 1 root root  5471544 Feb 11  2021  Aryanpur.idx
-rw-r--r-- 1 root root      157 Feb 11  2021  Aryanpur.ifo

I think this suggests connectivity issues. You see, the sources are still loading. Did you run python change_server_address.py inside http_server? This step is necessary if you would like to access SilverDict from a different machine.

The default server address is localhost. So that's why connection failed. The script updates the server address in the JS files to the actual IP address (192.168.xxx.xxx) of the machine on which SilverDict is run.

You may also find my newly edited guide useful.


I just remembered that you built the web app (yarn build) yourself. In this case, you can simply modify the API prefix in client/src/config.js and build again.

I think this suggests connectivity issues. You see, the sources are still loading. Did you run python change_server_address.py inside http_server? This step is necessary if you would like to access SilverDict from a different machine.

The default server address is localhost. So that's why connection failed. The script updates the server address in the JS files to the actual IP address (192.168.xxx.xxx) of the machine on which SilverDict is run.

You may also find my newly edited guide useful.

I just remembered that you built the web app (yarn build) yourself. In this case, you can simply modify the API prefix in client/src/config.js and build again.

HI @Crissium ,

I didn't know that running python change_server_address.py is necessary.
RTL Languages seems to be okay to me. :)
I'm very
image

Glad to know it works! If there are any further problems, let me know. I am more than willing to help.

Glad to know it works! If there are any further problems, let me know. I am more than willing to help.

i use cloudflare zero trust tunnels. I've set a new hostname for silverdict.
but when i call silverdict.mydomain.com i am not able to rescan the source files : (

image

I don't know much about Cloudflare Tunnels, and perhaps this link will help?

https://community.cloudflare.com/t/which-ports-can-i-use-with-tunnels/394194

The back-end server listens at 2628, and the custom HTTP server (which forwards /api requests to the backend) uses 8081. The protocol is just plain HTTP(S), so maybe you can try to proxy 8081?


By the way, here's how I myself deployed SilverDict to the cloud:

Browser -> Cloudflare CDN (443) -> Nginx (443) -> SilverDict (2628).

nginx here serves the static files of the web app.

thank you very much for your answer and effort. I don't really know much about nginx. I've been using cloudflare zero trust tunnel since I've began and it was really easy.
I would be very grateful if you could write and add a how-to on using Nginx or Apache web servers with your application.

I would be very grateful if you could write and add a how-to on using Nginx or Apache web servers with your application.

How to set up an nginx server with SSL varies across distros, but the basic steps are:

  1. Get a domain name.
  2. Get a server.
  3. Configure your DNS record to point the domain to the server's IP.
  4. Configure the server's firewall and open the relevant ports (80, 443 should be enough).
  5. Install nginx and certbot.
  6. Write an nginx config stub and put it inside /etc/nginx/vhosts.d (the exact path depends on your distro).
  7. Run certbot --nginx, which is interactive and very user-friendly.
  8. Set up a systemd timer for certbot to renew the certs.
  9. Configure the CDN if you need it.
  10. If the nginx example site shows up without a problem, put some configuration to let nginx proxy certain requests.

There are plenty of guides online about this process. And I'll write about how to make SilverDict work behind nginx. (My demo site does not use CDN, but does use nginx.)

Hi @shahram7 , I just wrote a guide about deploying behind nginx: https://github.com/Crissium/SilverDict/wiki/nginx#working-behind-nginx

If there are anything unclear, do let me know.

So I have got rid of the HTTP server completely and now you can just run SilverDict on port 80 with python server.py 0.0.0.0:80. Everything is there, including the web UI.

thank you @Crissium.
I have currently some hardware issues with my home mini server. I will test it ASAP and let you know.

So I have got rid of the HTTP server completely and now you can just run SilverDict on port 80 with python server.py 0.0.0.0:80. Everything is there, including the web UI.

Hi @Crissium, i hope you're doing well.
I've created a new LXC Container of Debian12 and tried to install silverdict.

I've followed your tutorial and run server.py and ca see following:

(sd) root@lxcSilverDIct:/home/SilverDict/server# python3 server.py
INFO:app.dictionaries:Dictionaries loaded into memory.
INFO:waitress:Serving on http://127.0.0.1:2628

but the app wont be opened :(
image

INFO:waitress:Serving on http://127.0.0.1:2628

I recently changed the default listening address to 127.0.0.1 for security reasons.

You can make it listen on all interface by passing an argument to it:

python server.py 0.0.0.0:80

Then you can access the server at [address]:80.

Or set the listening address in ~/.silverdict/preferences.yaml.

INFO:waitress:Serving on http://127.0.0.1:2628

I recently changed the default listening address to 127.0.0.1 for security reasons.

You can make it listen on all interface by passing an argument to it:

python server.py 0.0.0.0:80

Then you can access the server at [address]:80.

Or set the listening address in ~/.silverdict/preferences.yaml.

thank you :)
image