Fixed docker compose and added env variables
This commit is contained in:
parent
5f0224e423
commit
7a7e3bb2b3
25
compose.yml
25
compose.yml
|
@ -1,5 +1,3 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
image: mongo:bionic
|
image: mongo:bionic
|
||||||
|
@ -12,6 +10,20 @@ services:
|
||||||
MONGO_INITDB_DATABASE: bot
|
MONGO_INITDB_DATABASE: bot
|
||||||
volumes:
|
volumes:
|
||||||
- mongodb_data:/data/db
|
- 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:
|
fe-middleware:
|
||||||
image: oven/bun:1
|
image: oven/bun:1
|
||||||
|
@ -19,13 +31,12 @@ services:
|
||||||
command: bun run docker-dev
|
command: bun run docker-dev
|
||||||
working_dir: /usr/src/app
|
working_dir: /usr/src/app
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8081:8081"
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongodb
|
- bot-api
|
||||||
environment:
|
environment:
|
||||||
MONGODB_URI: "mongodb://mongodb:27017/bot"
|
PORT: 8081
|
||||||
MONGODB_USER: "root"
|
BOT_API_URI: "http://bot-api:8080"
|
||||||
MONGODB_PASS: "password"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/usr/src/app:ro
|
- ./:/usr/src/app:ro
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class ImageController {
|
||||||
const image = await ImageService.get();
|
const image = await ImageService.get();
|
||||||
res.json(image);
|
res.json(image);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
res.status(500).json({ "error": "Internal server error" });
|
res.status(500).json({ "error": `Internal server error: ${error}` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import { env } from "bun";
|
||||||
import app from "./app";
|
import app from "./app";
|
||||||
|
|
||||||
const PORT = 3000;
|
const PORT = env.PORT;
|
||||||
|
|
||||||
app.listen(PORT, () =>
|
app.listen(PORT, () =>
|
||||||
console.log(`Express server listening on port ${PORT}`)
|
console.log(`Express server listening on port ${PORT}`)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
import { env } from "bun";
|
||||||
import { BotApiResponse } from "../types/BotApiResponse";
|
import { BotApiResponse } from "../types/BotApiResponse";
|
||||||
|
|
||||||
class BotApiService {
|
class BotApiService {
|
||||||
readonly BOT_API_URL = "http://192.168.178.27:30000";
|
readonly BOT_API_URI = env.BOT_API_URI;
|
||||||
|
|
||||||
async getAll(): Promise<BotApiResponse> {
|
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)
|
const response: BotApiResponse = await fetch(get_url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|
Loading…
Reference in New Issue