Make ts-node a production dependency and use environment variables for configuration
This commit is contained in:
parent
c7f520c9b7
commit
33de8f9be6
|
@ -12,13 +12,13 @@ COPY . .
|
||||||
VOLUME /kill-the-newsletter/static/feeds/
|
VOLUME /kill-the-newsletter/static/feeds/
|
||||||
VOLUME /kill-the-newsletter/static/alternate/
|
VOLUME /kill-the-newsletter/static/alternate/
|
||||||
|
|
||||||
ENV WEB_PORT=8000
|
ENV WEB_PORT=4000
|
||||||
ENV EMAIL_PORT=2525
|
ENV EMAIL_PORT=2525
|
||||||
ENV BASE_URL=http://localhost:8000
|
ENV BASE_URL=http://localhost:4000
|
||||||
ENV EMAIL_DOMAIN=localhost
|
ENV EMAIL_DOMAIN=localhost
|
||||||
ENV ISSUE_REPORT=mailto:kill-the-newsletter@leafac.com
|
ENV ISSUE_REPORT=mailto:kill-the-newsletter@leafac.com
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 4000
|
||||||
EXPOSE 2525
|
EXPOSE 2525
|
||||||
|
|
||||||
CMD npx ts-node .
|
CMD npx ts-node .
|
|
@ -35,7 +35,8 @@
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"mailparser": "^3.1.0",
|
"mailparser": "^3.1.0",
|
||||||
"smtp-server": "^3.8.0",
|
"smtp-server": "^3.8.0",
|
||||||
"tagged-template-noop": "^2.1.1"
|
"tagged-template-noop": "^2.1.1",
|
||||||
|
"ts-node": "^9.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^4.17.11",
|
"@types/express": "^4.17.11",
|
||||||
|
@ -52,7 +53,6 @@
|
||||||
"nodemailer": "^6.4.18",
|
"nodemailer": "^6.4.18",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"ts-node": "^9.1.1",
|
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^4.2.3"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
|
|
@ -19,9 +19,15 @@ export default function killTheNewsletter(
|
||||||
): { webApplication: express.Express; emailApplication: SMTPServer } {
|
): { webApplication: express.Express; emailApplication: SMTPServer } {
|
||||||
const webApplication = express();
|
const webApplication = express();
|
||||||
|
|
||||||
webApplication.set("url", "http://localhost:4000");
|
const baseUrl = process.env.BASE_URL ?? "http://localhost:4000";
|
||||||
webApplication.set("email", "smtp://localhost:2525");
|
webApplication.set("url", baseUrl);
|
||||||
webApplication.set("administrator", "mailto:kill-the-newsletter@leafac.com");
|
|
||||||
|
const smtpUrl = process.env.SMTP_URL ?? "smtp://localhost:2525";
|
||||||
|
webApplication.set("email", smtpUrl);
|
||||||
|
|
||||||
|
const issueReportEmail =
|
||||||
|
process.env.ISSUE_REPORT_EMAIL ?? "kill-the-newsletter@leafac.com";
|
||||||
|
webApplication.set("administrator", `mailto:${issueReportEmail}`);
|
||||||
|
|
||||||
fs.ensureDirSync(rootDirectory);
|
fs.ensureDirSync(rootDirectory);
|
||||||
const database = new Database(
|
const database = new Database(
|
||||||
|
@ -503,11 +509,15 @@ if (require.main === module) {
|
||||||
const { webApplication, emailApplication } = killTheNewsletter(
|
const { webApplication, emailApplication } = killTheNewsletter(
|
||||||
path.join(process.cwd(), "data")
|
path.join(process.cwd(), "data")
|
||||||
);
|
);
|
||||||
webApplication.listen(new URL(webApplication.get("url")).port, () => {
|
const webPort =
|
||||||
console.log(`Web server started at ${webApplication.get("url")}`);
|
process.env.WEB_PORT ?? new URL(webApplication.get("url")).port;
|
||||||
|
webApplication.listen(webPort, () => {
|
||||||
|
console.log(`Web server started at port ${webPort}}`);
|
||||||
});
|
});
|
||||||
emailApplication.listen(new URL(webApplication.get("email")).port, () => {
|
const emailPort =
|
||||||
console.log(`Email server started at ${webApplication.get("email")}`);
|
process.env.EMAIL_PORT ?? new URL(webApplication.get("email")).port;
|
||||||
|
emailApplication.listen(emailPort, () => {
|
||||||
|
console.log(`Email server started at port ${emailPort}`);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const configurationFile = path.resolve(process.argv[2]);
|
const configurationFile = path.resolve(process.argv[2]);
|
||||||
|
|
Loading…
Reference in New Issue