chore: update Dockerfile and docker-compose for improved deployment process; add deploy script

This commit is contained in:
asepharyana
2026-07-05 22:06:52 +07:00
parent 20b622c4c2
commit bbf420759b
10 changed files with 236 additions and 23 deletions
+4 -2
View File
@@ -52,11 +52,13 @@ const maskSecret = (value: string): string => {
return `${value.slice(0, 6)}...${value.slice(-4)}`;
};
const maskDatabaseUrl = (value: string): string => value.replace(/:\/\/([^:]+):([^@]+)@/, '://$1:***@');
const maskDatabaseUrl = (value: string): string =>
value.replace(/:\/\/([^:]+):([^@]+)@/, '://$1:***@');
export const config: AppConfig = {
botToken: process.env.BOT_TOKEN!,
additionalBotTokens: process.env.NODE_ENV === 'test' ? [] : parseTokens(process.env.ADDITIONAL_BOT_TOKENS),
additionalBotTokens:
process.env.NODE_ENV === 'test' ? [] : parseTokens(process.env.ADDITIONAL_BOT_TOKENS),
storageChatId: parseInt(process.env.STORAGE_CHANNEL_ID!, 10),
baseUrl: process.env.BASE_URL!,
databaseUrl: process.env.DATABASE_URL!,
+1 -2
View File
@@ -43,8 +43,7 @@ const cleanupTempFile = async (tempPath: string): Promise<void> => {
const sanitizeFilenameHeader = (fileName: string): string =>
fileName.replace(/[\\"]/g, '').replace(/[\n\r]/g, '');
const fail = (status: number, error: string): Response =>
Response.json({ error }, { status });
const fail = (status: number, error: string): Response => Response.json({ error }, { status });
export const handleFileRedirect = async (req: RequestWithParams): Promise<Response> => {
const public_id = req.params?.public_id;
+2 -1
View File
@@ -90,7 +90,8 @@ export const handleSwaggerJson = async (): Promise<Response> => {
'/api/upload': {
post: {
summary: 'Upload File',
description: 'Uploads a file to Telegram storage via multipart/form-data or JSON base64. Rate-limited by IP.',
description:
'Uploads a file to Telegram storage via multipart/form-data or JSON base64. Rate-limited by IP.',
requestBody: {
required: true,
content: {
+4 -1
View File
@@ -231,7 +231,10 @@ const handleJSONUpload = async (req: Request): Promise<Response> => {
const { base64Data, mimeType: rawMimeType } = parseBase64File(file);
const estimatedSizeBytes = Math.floor((base64Data.length * 3) / 4);
if (estimatedSizeBytes > JSON_UPLOAD_LIMIT_BYTES || estimatedSizeBytes > config.maxRequestBodyBytes) {
if (
estimatedSizeBytes > JSON_UPLOAD_LIMIT_BYTES ||
estimatedSizeBytes > config.maxRequestBodyBytes
) {
return Response.json(
{
error:
-5
View File
@@ -5,11 +5,6 @@ import { enqueueUpload } from './telegramQueue';
const botTokens = Array.from(new Set([config.botToken, ...config.additionalBotTokens]));
type FileInfoResult = {
result: unknown;
botToken: string;
};
const bots = botTokens.map((token) => new Telegraf(token));
let nextBotIndex = 0;
+4 -1
View File
@@ -140,7 +140,10 @@ export const enqueuePreparedUpload = (item: BatchUploadItem): Promise<UploadedFi
}, BATCH_WINDOW_MS);
}
if (pendingUploads.length >= config.batchMaxItems || getPendingSize() >= config.batchMaxSizeBytes) {
if (
pendingUploads.length >= config.batchMaxItems ||
getPendingSize() >= config.batchMaxSizeBytes
) {
void flushUploads();
}
});
+1 -1
View File
@@ -1,8 +1,8 @@
import { once } from 'node:events';
import { createReadStream, createWriteStream } from 'node:fs';
import { finished } from 'node:stream/promises';
import { open, stat } from 'node:fs/promises';
import { basename } from 'node:path';
import { finished } from 'node:stream/promises';
import { nanoid } from 'nanoid';
export type ZipInputFile = {