avoonix / material-e621

Material e621 is a modern, open source web client for e621.net. It is customizable, comes with a bunch of additional features that are not available on e621.net, and makes browsing posts a delightful experience.
https://material-e621.vercel.app
GNU Affero General Public License v3.0
54 stars 6 forks source link

[Feature]: Docker Image #3

Closed avoonix closed 1 year ago

avoonix commented 1 year ago

Create a docker image for easier self hosting #2

tamaskan commented 1 year ago

tried a dockerfile with:

FROM alpine/git:latest RUN apk add --update nodejs npm WORKDIR /app RUN git clone https://github.com/avoonix/material-e621 RUN cd /app/material-e621 && npm install WORKDIR /app/material-e621 EXPOSE 5173 ENTRYPOINT ["npm", "run","dev","--", "--host", "0.0.0.0"]

and it's working. There seems to be only an issue with the loading of posts ( SyntaxError: import declarations may only appear at top level of a module in src/worker/ApiServiceWorker?type=module&worker_file )

avoonix commented 1 year ago

npm run dev is for the unoptimized development build, which sadly still doesn't work in Firefox (and some other browsers). Serving the output from npm run build should work for everywhere.

tamaskan commented 1 year ago

great, "npm run build && npm run preview -- --host 0.0.0.0 --port 80" did work :-)

is it possible to automatically store a backup of the indexed-db on the server ? ( maybe with https://www.npmjs.com/package/vite-plugin-fs ? )

tamaskan commented 1 year ago

the only other things for a docker-image would be the option to customize the proxy-urls in this repo (maybe settings->proxy with a verify and save button ?) and the proxy-repo

avoonix commented 1 year ago

is it possible to automatically store a backup of the indexed-db on the server ? ( maybe with https://www.npmjs.com/package/vite-plugin-fs ? )

Yes, since both https://github.com/avoonix/material-e621/blob/bdbdea12f6256572aeeb2fb712767c6371bf1cee/src/services/PersistanceService.ts#L29-L32 and https://github.com/avoonix/material-e621/blob/bdbdea12f6256572aeeb2fb712767c6371bf1cee/src/services/PersistanceService.ts#L33-L43 are async, you can just put network calls in there if you wish (maybe also debounce it). But that is not something I'd like to support out of the box.

tamaskan commented 1 year ago

i managed to do that :-) i think i need to create a fork for a private version of this

tamaskan commented 1 year ago

Added a nginx-version to his pull request

avoonix commented 1 year ago

Thanks for all the input. I used your dockerfile as starting point, but ended up changing quite a bit. Let me know if any of the changes in cc751c8 or 534b7b7 don't work for you.

https://github.com/avoonix/material-e621/pkgs/container/material-e621

Instructions:

sudo docker run -d -p 8080:80 ghcr.io/avoonix/material-e621:latest

or

version: "3"
services:
  app:
    image: ghcr.io/avoonix/material-e621:latest
    # if you want to build it yourself, replace `image` with `build`
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    ports:
      - 8080:80