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"]
# 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);
});
});
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);
});
});
No description
No description
Solution:
Solved: the problem was not related to Sapphire. I had to allocate a persistent CPU...
Jump to solution
2 Replies
Mercenary Ike
Mercenary IkeOP3w ago
Further: in the first deploy, there were problems with the token, so an error is properly logged. But right now, there is no logging from Discord at all. Refer to the first screenshot
Solution
Mercenary Ike
Mercenary Ike2w ago
Solved: the problem was not related to Sapphire. I had to allocate a persistent CPU
Want results from more Discord servers?
Add your server