mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
chore: fix for development docker-compose
This commit is contained in:
@@ -27,10 +27,6 @@ app.use('/', webRouter)
|
|||||||
app.use('/SASjsApi', apiRouter)
|
app.use('/SASjsApi', apiRouter)
|
||||||
app.use(express.json({ limit: '50mb' }))
|
app.use(express.json({ limit: '50mb' }))
|
||||||
|
|
||||||
try {
|
app.use(express.static(getWebBuildFolderPath()))
|
||||||
app.use(express.static(getWebBuildFolderPath()))
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Unable to get web build')
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connectDB().then(() => app)
|
export default connectDB().then(() => app)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
import { configuration } from '../package.json'
|
|
||||||
import appPromise from './app'
|
import appPromise from './app'
|
||||||
|
|
||||||
const keyPath = path.join('..', 'certificates', 'privkey.pem')
|
const keyPath = path.join('..', 'certificates', 'privkey.pem')
|
||||||
@@ -13,9 +12,10 @@ const cert = readFileSync(certPath)
|
|||||||
appPromise.then((app) => {
|
appPromise.then((app) => {
|
||||||
const httpsServer = https.createServer({ key, cert }, app)
|
const httpsServer = https.createServer({ key, cert }, app)
|
||||||
|
|
||||||
httpsServer.listen(configuration.sasJsPort, () => {
|
const sasJsPort = process.env.PORT ?? 5000
|
||||||
|
httpsServer.listen(sasJsPort, () => {
|
||||||
console.log(
|
console.log(
|
||||||
`⚡️[server]: Server is running at https://localhost:${configuration.sasJsPort}`
|
`⚡️[server]: Server is running at https://localhost:${sasJsPort}`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ const codeToInject = `
|
|||||||
</script>`
|
</script>`
|
||||||
|
|
||||||
webRouter.get('/', async (_, res) => {
|
webRouter.get('/', async (_, res) => {
|
||||||
let indexHtmlPath: string
|
const indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
|
||||||
|
if (!(await fileExists(indexHtmlPath))) {
|
||||||
try {
|
|
||||||
indexHtmlPath = path.join(getWebBuildFolderPath(), 'index.html')
|
|
||||||
} catch (err) {
|
|
||||||
return res.send('Web Build is not present')
|
return res.send('Web Build is not present')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import appPromise from './app'
|
import appPromise from './app'
|
||||||
import { configuration } from '../package.json'
|
|
||||||
|
|
||||||
appPromise.then((app) => {
|
appPromise.then((app) => {
|
||||||
app.listen(configuration.sasJsPort, () => {
|
const sasJsPort = process.env.PORT ?? 5000
|
||||||
|
app.listen(sasJsPort, () => {
|
||||||
console.log(
|
console.log(
|
||||||
`⚡️[server]: Server is running at http://localhost:${configuration.sasJsPort}`
|
`⚡️[server]: Server is running at http://localhost:${sasJsPort}`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from 'path'
|
|||||||
import { getRealPath } from '@sasjs/utils'
|
import { getRealPath } from '@sasjs/utils'
|
||||||
|
|
||||||
export const getWebBuildFolderPath = () =>
|
export const getWebBuildFolderPath = () =>
|
||||||
getRealPath(path.join(__dirname, '..', '..', '..', 'web', 'build'))
|
path.join(__dirname, '..', '..', '..', 'web', 'build')
|
||||||
|
|
||||||
export const getTmpFolderPath = () =>
|
export const getTmpFolderPath = () =>
|
||||||
process.driveLoc ?? getRealPath(path.join(process.cwd(), 'tmp'))
|
process.driveLoc ?? getRealPath(path.join(process.cwd(), 'tmp'))
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ services:
|
|||||||
image: sasjs_server_api
|
image: sasjs_server_api
|
||||||
build: ./api
|
build: ./api
|
||||||
environment:
|
environment:
|
||||||
|
MODE: server
|
||||||
|
CORS: enable
|
||||||
|
PORT: 5000
|
||||||
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
build
|
build
|
||||||
node_modules
|
node_modules
|
||||||
Dockerfile
|
Dockerfile
|
||||||
|
|||||||
Reference in New Issue
Block a user