serving built app on port 3000 when starting with fastify

this eases up scalingo deployment
This commit is contained in:
Emmanuel Pelletier
2024-05-02 01:11:01 +02:00
parent 0ce04a420d
commit 14044e95a4
3 changed files with 991 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
"version": "0.1.0",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"start": "node ./server.mjs",
"build-backgrounds": "node ./bin/build-services-backgrounds.mjs",
"build": "astro check && npm run build-backgrounds && astro build",
"copy-logos": "cp -r ./node_modules/@gouvfr-lasuite/integration/dist/logos/* ./src/assets/logos",
@@ -18,11 +18,13 @@
"@astrojs/markdown-remark": "^5.1.0",
"@astrojs/react": "^3.3.1",
"@astrojs/starlight": "^0.21.5",
"@fastify/static": "^7.0.3",
"@gouvfr-lasuite/integration": "^0.1.0",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/react-syntax-highlighter": "^15.5.11",
"astro": "^4.3.5",
"fastify": "^4.26.2",
"prettier": "^3.2.5",
"prettier-plugin-astro": "^0.13.0",
"prismjs": "^1.29.0",

17
website/server.mjs Normal file
View File

@@ -0,0 +1,17 @@
import { join } from "path"
import Fastify from "fastify"
import staticMiddleware from "@fastify/static"
const fastify = Fastify({
logger: true,
})
fastify.register(staticMiddleware, {
root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"),
})
try {
fastify.listen({ port: process.env.PORT || 3000 })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}