syncribullet icon indicating copy to clipboard operation
syncribullet copied to clipboard

Dockerfile & GitHub Actions

Open anil-sezer opened this issue 8 months ago • 8 comments

Hey yo Aliyss, hi! I'm trying to Dockerize your app so it can be deployed in anywhere easily. I will create a clean PR to you after a successful run.

There is two problems I encountered and since I'm a c# Backend & DevOps guy, my experience with JS is waay limited so I currently no idea how to debug the addon. First problem is this:


> [email protected] start
> ORIGIN=https://56bca7d190fc-syncribullet.baby-beamup.club node server/entry.express

Server started: http://localhost:3000/
TypeError: Cannot read properties of null (reading 'substring')
    at sa (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:2750)
    at Xr (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:3323)
    at bt (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:5563)
    at Vp (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:342:12574)
    at Object.g [as next] (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:3549)
    at async el (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:6568)
    at async router (file:///app/server/entry.express.mjs:1:3940)
Error: Failed to decrypt and decompress
    at bt (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:5607)
    at Vp (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:342:12574)
    at Object.g [as next] (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:3549)
    at async el (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:6568)
    at async router (file:///app/server/entry.express.mjs:1:3940)
Error: Failed to decrypt and decompress
    at bt (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:5607)
    at Vp (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:342:12574)
    at Object.g [as next] (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:3549)
    at async el (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:6568)
    at async router (file:///app/server/entry.express.mjs:1:3940)

Second is this, many of this when I try to access movies:

TypeError: Cannot read properties of null (reading 'movies')
    at Tp._getMetaPreviews (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:342:164)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Tp.getMetaPreviews (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:33:37695)
    at async Op (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:342:8273)
    at async Object.g [as next] (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:3576)
    at async el (file:///app/server/assets/@qwik-city-plan-99564c68.mjs:18:6568)
    at async router (file:///app/server/entry.express.mjs:1:3940)

Concerning following

  • [ ] Anilist
  • [x] Simkl
  • [ ] Stremio
  • [x] SyncriBullet Website
  • [x] AIOStreams Feature

Stremio Version:

  • [ ] 4.x
  • [ ] 5.x beta

SyncriBullet Version is up to date:

  • [x] I confirm I'm using the latest version of the add-on

** Occurs on **

  • [ ] Mobile
  • [ ] Desktop
  • [ ] TV
  • [ ] Web

Screenshots

Image

What can we do about this? Aand thank you for your time!

anil-sezer avatar Apr 06 '25 09:04 anil-sezer

@anil-sezer can you share your fork of what you already have? Would make it easier for me to check what is going on.

aliyss avatar Apr 06 '25 13:04 aliyss

I got the latest of your master branch, only this Dockerfile is added to the project root for now. After the fixes I can also add the Github actions for multi platform automated build and push. I can also add multi stage builds for reduced image size if its possible with nodejs.

# docker build -t syncribullet:local .
# docker run --rm -it -p 3000:3000 syncribullet:local

# For multi platform builds:
# docker buildx build --platform linux/amd64,linux/arm64 -t anilsezer/syncribullet:experimental --push . --progress=plain

# linux/arm/v7 is not widely supported so this command might not work. For example, prism does not support it: 
# docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t anilsezer/syncribullet:experimental --push . --progress=plain

FROM node:22.14.0-alpine3.21
RUN echo "NPM Version:" && npm -v
RUN echo "Node Version:" && node -v

WORKDIR /app

# Copy only package files first for caching
COPY package.json package-lock.json ./

#RUN npm ci
RUN npm install

# Copy the rest of the application files
COPY . .

RUN npm run build

EXPOSE 3000

# Start the application
CMD ["npm", "run", "start"]

If Docker is not installed, you can use this: https://docs.docker.com/desktop/

While you are at the project root, run these commands:

docker build -t syncribullet:test . 
docker run --rm -it -p 3000:3000 syncribullet:test

Then you should be able to access http://localhost:3000/ @aliyss

anil-sezer avatar Apr 07 '25 07:04 anil-sezer

Hi again @aliyss , did you had time to check it out? Can I help somehow?

anil-sezer avatar Apr 15 '25 19:04 anil-sezer

@anil-sezer done. I pushed the changes. So latest don't error out anymore.

Do me a favor and include an env variable with the following contents in the Dockerfile:

PRIVATE_ENCRYPTION_KEY=[AUTOGENERATED_ENKRYPTION_KEY]

where the AUTOGENERATED_ENKRYPTION_KEY (without brackets) only consists of UPPERCASE and lowercase a-zA-Z characters.

To test it go to following path and console.log: env.get('PRIVATE_ENCRYPTION_KEY')

The env variable should automatically be generated in the Dockerfile only if .env.local does not exist.

aliyss avatar Apr 15 '25 21:04 aliyss

Thank you! It works smoothly!

I'm not sure if I understood your request correctly so I will try to clarify:

If we want to add AUTOGENERATED_ENCRYPTION_KEY only on build stage, we should add it as an ARG to the Dockerfile. If we want it at runtime, then it should be ENV. If we want both, then we should add it two times, like this:

ARG AUTOGENERATED_ENCRYPTION_KEY

ENV AUTOGENERATED_ENCRYPTION_KEY=${AUTOGENERATED_ENCRYPTION_KEY}

Usage: docker build --build-arg AUTOGENERATED_ENCRYPTION_KEY=my-secret-key -t syncribullet:local . And/Or docker run -e AUTOGENERATED_ENCRYPTION_KEY=my-runtime-key -t syncribullet:local

I also tried to display that env variable in various places like inside the container, at the webpage console etc but could not find it but the addon works.

anil-sezer avatar Apr 25 '25 06:04 anil-sezer

If possible:

Automatically create at build time.

test if env=AUTOGENERATED_ENCRYPTION_KEY exists at runtime

Otherwise use what was created at buildtine

aliyss avatar Apr 26 '25 02:04 aliyss

Hi again! Sorry for my laaaate reply.

If we create it at the build time, then everyone who uses that image will use the same encryption key. If its not going to create a problem then lets do it. I'm mentioning this because we might want to add GitHub image build action later, which will result in fewer questions to us since they can directly deploy with a single command. I can clarify this concept if you wish, no problem btw.

Can you send me the command for triggering generation of that key? I can adapt that command to the build flow if that's what we want to do.

anil-sezer avatar Apr 28 '25 19:04 anil-sezer

Ping me on discord. Let's chat it through might be easier. Username: aliyss

aliyss avatar Apr 28 '25 20:04 aliyss

https://hub.docker.com/r/aliyss/syncribullet

@anil-sezer If you don't mind relinking on your end. Btw. thanks for the initial Dockerfile.

aliyss avatar Nov 01 '25 12:11 aliyss

Nice! Congrats on Docker, you are gonna love containers ease of use

anil-sezer avatar Nov 01 '25 13:11 anil-sezer