Google Cloud Run not logging into the bot

Hello devs,

I am using Cloud Run to run a Discord bot docker image built like this:
# 1. Build

FROM node:20-slim as BUILD

WORKDIR /condor

COPY . .

RUN npm install && npm run compile

# 2. Export

FROM node:20-slim

WORKDIR /condor

ARG TOKEN
ARG EMOJI_SERVER_ID
ARG OPENAI_API_KEY
ARG FB_PROJECT_ID
ARG FB_PRIVATE_KEY
ARG FB_CLIENT_EMAIL
ARG GOOGLEAPI_PRIVATE_KEY
ARG GOOGLEAPI_CLIENT_EMAIL
ARG CLOUDRUN_PORT

ENV TOKEN=$TOKEN
ENV EMOJI_SERVER_ID=$EMOJI_SERVER_ID
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV FB_PROJECT_ID=$FB_PROJECT_ID
ENV FB_PRIVATE_KEY=$FB_PRIVATE_KEY
ENV FB_CLIENT_EMAIL=$FB_CLIENT_EMAIL
ENV GOOGLEAPI_PRIVATE_KEY=$GOOGLEAPI_PRIVATE_KEY
ENV GOOGLEAPI_CLIENT_EMAIL=$GOOGLEAPI_CLIENT_EMAIL
ENV CLOUDRUN_PORT=$CLOUDRUN_PORT

COPY package.json ./
COPY tsconfig.json ./

RUN ls -la && npm install --omit=dev

COPY --from=BUILD /condor/dist ./dist

CMD ["sh", "-c", "npm run start || tail -f /dev/null"]


Everything is defined properly, but
bot.login
doesn't seem to be registering in the Cloud Run, because neither
.then
nor
.catch
were called.

import bot from '@bot';
import { ApplicationCommandRegistries, RegisterBehavior } from "@sapphire/framework";
import * as http from 'http';

// require('dotenv').config();

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

const server = http.createServer((req, res) => {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Just for testing purposes\n');
});
    
server.listen(process.env.CLOUDRUN_PORT, () => {
    console.log('Server running at http://localhost:' + process.env.CLOUDRUN_PORT + '/');
    console.log(`bot.id: ${bot.id}`)
    console.log(`TOKEN: ${process.env.TOKEN}`)
    bot.login(process.env.TOKEN)
        .then(() => {
            console.log('Bot is ready');
        })
        .catch((error) => {
            console.error('Error while logging in', error);
        });
});
2024-11-05_162412.png
2024-11-05_161809.png
Solution
Solved: the problem was not related to Sapphire.
I had to allocate a persistent CPU
Was this page helpful?