dockerfile add tsc command

This commit is contained in:
Kfir Dayan 2023-04-03 19:52:41 +03:00
parent cfc2d3bc9a
commit 7859110d97
6 changed files with 36 additions and 14 deletions

View file

@ -1,4 +1,3 @@
node_modules node_modules
npm-debug.log npm-debug.log
src
tmp tmp

View file

@ -9,6 +9,9 @@ WORKDIR /usr/src/app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
RUN npm install -g typescript
# If you are building your code for production # If you are building your code for production
# RUN npm ci --omit=dev # RUN npm ci --omit=dev
@ -16,4 +19,10 @@ RUN npm install
COPY . . COPY . .
EXPOSE ${PORT} EXPOSE ${PORT}
CMD [ "node", "dist/index.js" ]
# run npm build to create the dist folder
RUN tsc
# run npm start to start the server
CMD [ "npm", "start" ]

16
package-lock.json generated
View file

@ -16,7 +16,8 @@
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/node": "^18.15.5" "@types/node": "^18.15.5",
"typescript": "^5.0.3"
} }
}, },
"node_modules/@babel/runtime": { "node_modules/@babel/runtime": {
@ -1293,6 +1294,19 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/typescript": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz",
"integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=12.20"
}
},
"node_modules/unpipe": { "node_modules/unpipe": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",

View file

@ -11,11 +11,12 @@
}, },
"scripts": { "scripts": {
"dev": "nodemon dist/index.js", "dev": "nodemon dist/index.js",
"build": "tsc", "build": "npx tsc",
"start": "node dist/index.js" "start": "node dist/index.js"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/node": "^18.15.5" "@types/node": "^18.15.5",
"typescript": "^5.0.3"
} }
} }

View file

@ -7,11 +7,6 @@ import env from 'dotenv';
env.config(); env.config();
const CronJob = require('cron').CronJob;
class App { class App {
googleCalendar: GoogleCalendar; googleCalendar: GoogleCalendar;
gameSource: GameSource; gameSource: GameSource;
@ -40,6 +35,8 @@ class App {
const app = new App(); const app = new App();
console.log("Declaring Cron Job every day at 10:00") console.log("Declaring Cron Job every day at 10:00")
const CronJob = require('cron').CronJob;
const job = new CronJob( const job = new CronJob(
"0 10 * * *", // every day at 10:00, "0 10 * * *", // every day at 10:00,
async () => { async () => {
@ -62,10 +59,9 @@ const webServer = express();
webServer.use(express.static('public')) webServer.use(express.static('public'))
webServer.listen(process.env.PORT, () => { webServer.listen(process.env.PORT, () => {
console.log('Example app listening on port '+process.env.PORT+'!') console.log(`Calender app listening on port ${process.env.PORT}!`)
}) })
// when client try to access 404 file
webServer.use(function (req, res, next) { webServer.use(function (req, res, next) {
res.status(404).send("Sorry can't find that!") res.status(404).send("Sorry can't find that!")
}) })

View file

@ -7,5 +7,8 @@
"moduleResolution": "node", "moduleResolution": "node",
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src"
} },
"include": [
"src/**/*"
]
} }