refactor: new dev/prod containers
- Use a single Dockerfile for all Zeppelin services - Add a Dockerfile in project root that can be used by app hosting services - Provide a standalone and lightweight prod setup - Standalone is the same as the old setup, with mysql+nginx - Lightweight only runs bot+backend+dash, no mysql/nginx - Remove mounted mysql data folders for dev and prod - This resolves permission issues caused by the mount - The mysql service uses a regular named volume now - Simplify .env options and clearly separate different prod setups - Remove update.sh - Different setups require different update procedures, so a common update.sh no longer works
This commit is contained in:
parent
730b8c1d6b
commit
509d96ce83
30 changed files with 948 additions and 274 deletions
|
@ -1,6 +1,7 @@
|
|||
import moment from "moment-timezone";
|
||||
import path from "path";
|
||||
import { DataSource } from "typeorm";
|
||||
import { MysqlConnectionOptions } from "typeorm/driver/mysql/MysqlConnectionOptions.js";
|
||||
import { env } from "../env";
|
||||
import { backendDir } from "../paths";
|
||||
|
||||
|
@ -9,13 +10,39 @@ moment.tz.setDefault("UTC");
|
|||
const entities = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/data/entities/*.js"));
|
||||
const migrations = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/migrations/*.js"));
|
||||
|
||||
type DbOpts = Pick<MysqlConnectionOptions, "host" | "port" | "username" | "password" | "database">;
|
||||
let dbOpts: DbOpts;
|
||||
if (env.HOST_MODE === "development") {
|
||||
dbOpts = {
|
||||
host: "mysql",
|
||||
port: 3306,
|
||||
username: "zeppelin",
|
||||
password: env.DEVELOPMENT_MYSQL_PASSWORD,
|
||||
database: "zeppelin",
|
||||
};
|
||||
} else if (env.HOST_MODE === "standalone") {
|
||||
dbOpts = {
|
||||
host: "mysql",
|
||||
port: 3306,
|
||||
username: "zeppelin",
|
||||
password: env.STANDALONE_MYSQL_PASSWORD,
|
||||
database: "zeppelin",
|
||||
};
|
||||
} else if (env.HOST_MODE === "lightweight") {
|
||||
dbOpts = {
|
||||
host: env.LIGHTWEIGHT_DB_HOST,
|
||||
port: env.LIGHTWEIGHT_DB_PORT,
|
||||
username: env.LIGHTWEIGHT_DB_USER,
|
||||
password: env.LIGHTWEIGHT_DB_PASSWORD,
|
||||
database: env.LIGHTWEIGHT_DB_DATABASE,
|
||||
};
|
||||
} else {
|
||||
throw new Error(`Unknown host mode: ${env.HOST_MODE}`);
|
||||
}
|
||||
|
||||
export const dataSource = new DataSource({
|
||||
type: "mysql",
|
||||
host: env.DB_HOST,
|
||||
port: env.DB_PORT,
|
||||
username: env.DB_USER,
|
||||
password: env.DB_PASSWORD,
|
||||
database: env.DB_DATABASE,
|
||||
...dbOpts,
|
||||
charset: "utf8mb4",
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue