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
npm-debug.log
src
tmp

View file

@ -9,6 +9,9 @@ WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install -g typescript
# If you are building your code for production
# RUN npm ci --omit=dev
@ -16,4 +19,10 @@ RUN npm install
COPY . .
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": {
"@types/express": "^4.17.17",
"@types/node": "^18.15.5"
"@types/node": "^18.15.5",
"typescript": "^5.0.3"
}
},
"node_modules/@babel/runtime": {
@ -1293,6 +1294,19 @@
"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": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",

View file

@ -11,11 +11,12 @@
},
"scripts": {
"dev": "nodemon dist/index.js",
"build": "tsc",
"build": "npx tsc",
"start": "node dist/index.js"
},
"devDependencies": {
"@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();
const CronJob = require('cron').CronJob;
class App {
googleCalendar: GoogleCalendar;
gameSource: GameSource;
@ -40,6 +35,8 @@ class App {
const app = new App();
console.log("Declaring Cron Job every day at 10:00")
const CronJob = require('cron').CronJob;
const job = new CronJob(
"0 10 * * *", // every day at 10:00,
async () => {
@ -62,10 +59,9 @@ const webServer = express();
webServer.use(express.static('public'))
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) {
res.status(404).send("Sorry can't find that!")
})

View file

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