Fixed docker compose and added env variables

This commit is contained in:
Sugui 2024-04-15 11:51:04 +02:00
parent 5f0224e423
commit 7a7e3bb2b3
4 changed files with 25 additions and 11 deletions

View File

@ -1,5 +1,3 @@
version: "3"
services:
mongodb:
image: mongo:bionic
@ -13,19 +11,32 @@ services:
volumes:
- mongodb_data:/data/db
bot-api:
image: git.fai.st/fedi-image-bot/bot-api:latest
container_name: bot-api
ports:
- "8080:8080"
depends_on:
- mongodb
environment:
PORT: 8080
MONGODB_URI: "mongodb://mongodb:27017/bot"
MONGODB_USER: "root"
MONGODB_PASS: "password"
JWTSECRET: "cooljwtsecret"
fe-middleware:
image: oven/bun:1
container_name: fe-middleware
command: bun run docker-dev
working_dir: /usr/src/app
ports:
- "8080:8080"
- "8081:8081"
depends_on:
- mongodb
- bot-api
environment:
MONGODB_URI: "mongodb://mongodb:27017/bot"
MONGODB_USER: "root"
MONGODB_PASS: "password"
PORT: 8081
BOT_API_URI: "http://bot-api:8080"
volumes:
- ./:/usr/src/app:ro

View File

@ -7,7 +7,7 @@ class ImageController {
const image = await ImageService.get();
res.json(image);
} catch (error: any) {
res.status(500).json({ "error": "Internal server error" });
res.status(500).json({ "error": `Internal server error: ${error}` });
}
}
}

View File

@ -1,6 +1,7 @@
import { env } from "bun";
import app from "./app";
const PORT = 3000;
const PORT = env.PORT;
app.listen(PORT, () =>
console.log(`Express server listening on port ${PORT}`)

View File

@ -1,10 +1,12 @@
import { env } from "bun";
import { BotApiResponse } from "../types/BotApiResponse";
class BotApiService {
readonly BOT_API_URL = "http://192.168.178.27:30000";
readonly BOT_API_URI = env.BOT_API_URI;
async getAll(): Promise<BotApiResponse> {
const get_url = `${this.BOT_API_URL}/images`;
const get_url = `${this.BOT_API_URI}/images`;
console.log(`Connecting to "${get_url}"...`)
const response: BotApiResponse = await fetch(get_url)
.then(res => {
if (!res.ok) {