Sapphire not initializing correctly inside of Docker

I have a bot that works just fine when running outside of Docker, and although my Docker container starts, it does not initialize Sapphire correctly (although the ready event does fire) Outside of Docker:
ready
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Successfully logged in as Lilith Dev (1128435995516358707)
[INFO] ApplicationCommandRegistries: Took 3ms to initialize.
ready
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Successfully logged in as Lilith Dev (1128435995516358707)
[INFO] ApplicationCommandRegistries: Took 3ms to initialize.
Inside Docker (same token and environment variables):
ready
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 0ms to initialize.
ready
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 0ms to initialize.
Solution:
i fixed this by doing ```dockerfile WORKDIR /usr/src/app/services/bot/build ...
Jump to solution
9 Replies
nea
neaOP17mo ago
I'm using my own Dockerfile (and using /common/deploy because rush monorepo)
FROM node:20.4-alpine3.17 AS runner
ENV NODE_ENV production

WORKDIR /usr/src/app

COPY ./common/deploy .
FROM node:20.4-alpine3.17 AS runner
ENV NODE_ENV production

WORKDIR /usr/src/app

COPY ./common/deploy .
i looked at examples of sapphire with docker and docker-compose and i don't think im missing anything (node_modules are already linked with pnpm inside /common/deploy, that's just how rush works)
Solution
nea
nea17mo ago
i fixed this by doing
WORKDIR /usr/src/app/services/bot/build

CMD ["node", "index.js"]
WORKDIR /usr/src/app/services/bot/build

CMD ["node", "index.js"]
instead of
CMD ["node", "services/bot/buildindex.js"]
CMD ["node", "services/bot/buildindex.js"]
nea
neaOP17mo ago
i do not know why this magically works but it does
Favna
Favna17mo ago
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and
nea
neaOP17mo ago
yeah, but my "main" in package.json is set correctly and outside of docker I can be in whatever folder I want to run the bot
Favna
Favna17mo ago
Outside of docker you probably also use something like npm run start I assume...?
nea
neaOP17mo ago
sometimes, but i also tried with just raw node in different folders as long as it works now ¯\_(ツ)_/¯
Favna
Favna17mo ago
Well anyway point being the cwd matters
nea
neaOP17mo ago
alr
Want results from more Discord servers?
Add your server