-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* temp * fix static * clean up scripts * unify env var * fix Dockerfile * more cleanup * update readme * fix tsconfig
- Loading branch information
Showing
43 changed files
with
10,184 additions
and
34,713 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
node_modules | ||
static/build/ | ||
frontend/assets.json | ||
frontend-server/config.json | ||
frontend-server/bundle.js* | ||
frontend-dist/ | ||
node_modules/ | ||
dist/ | ||
config.json | ||
stats.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
FROM node:16 AS builder | ||
|
||
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml /app/ | ||
|
||
COPY shared/package.json /app/shared/ | ||
COPY frontend-server/package.json /app/frontend-server/ | ||
COPY frontend/package.json /app/frontend/ | ||
|
||
RUN pnpm install --frozen-lockfile | ||
|
||
COPY . . | ||
RUN pnpm -C frontend-server run build | ||
RUN pnpm -C frontend run build-assets | ||
RUN pnpm -C frontend run build-server | ||
|
||
|
||
FROM node:16 | ||
|
||
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json /app/ | ||
RUN npm ci && npm cache clean --force | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml /app/ | ||
|
||
COPY shared /app/shared | ||
COPY frontend-server /app/frontend-server | ||
RUN npm run build-dist | ||
RUN cp frontend-server/*.ejs frontend-dist/ | ||
COPY shared/package.json /app/shared/ | ||
COPY frontend-server/package.json /app/frontend-server/ | ||
COPY frontend/package.json /app/frontend/ | ||
|
||
COPY static /app/static | ||
RUN pnpm -C frontend-server install --frozen-lockfile --prod | ||
|
||
COPY frontend /app/frontend | ||
RUN npm run build-assets | ||
RUN npm run build-server | ||
RUN cp frontend/assets.json frontend-server/bundle.js frontend-server/bundle.js.map frontend-dist/ | ||
COPY --from=builder /app/shared /app/shared | ||
COPY --from=builder /app/frontend-server /app/frontend-server | ||
COPY --from=builder /app/frontend/dist /app/frontend/dist | ||
|
||
ENV NODE_ENV production | ||
ENV ANIMETA_FRONTEND_DIST_PATH /app/frontend/dist | ||
|
||
CMD ["node", "frontend-dist/frontendServer.js"] | ||
CMD ["node", "frontend-server/dist/frontendServer.js"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@animeta/web-frontend-server", | ||
"private": true, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "pnpm run clean && tsc --build && cp -r src/views dist/", | ||
"clean": "rm -rf dist/", | ||
"start": "pnpm run build && node dist/frontendServer.js" | ||
}, | ||
"devDependencies": { | ||
"@types/cookie-parser": "^1.4.3", | ||
"@types/csurf": "^1.11.2", | ||
"@types/express": "^4", | ||
"@types/express-serve-static-core": "^4.17.30", | ||
"@types/http-proxy": "^1.17.5", | ||
"@types/lodash": "^4.14.165", | ||
"@types/react": "^17.0.46", | ||
"@types/request": "^2.48.3", | ||
"@types/serialize-javascript": "^5.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.2" | ||
}, | ||
"dependencies": { | ||
"@animeta/web-shared": "workspace:*", | ||
"@sentry/node": "^6.19.7", | ||
"cookie-parser": "^1.4.6", | ||
"csurf": "^1.11.0", | ||
"ejs": "^2.3.4", | ||
"express": "^4.18.1", | ||
"graphql": "^16.6.0", | ||
"graphql-request": "^4.3.0", | ||
"http-proxy": "^1.18.1", | ||
"lodash": "^4.17.21", | ||
"nuri": "github:dittos/nuri-builds#1be420c859a8097bbbfe9e1f7a182954343a7182", | ||
"react": "^17.0.2", | ||
"request": "^2.85.0", | ||
"serialize-javascript": "^1.9.1" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import * as Sentry from '@sentry/node'; | ||
import { createServer } from './frontend'; | ||
import { DefaultAppProvider } from './AppProvider'; | ||
|
||
const config = JSON.parse(fs.readFileSync(process.env.ANIMETA_CONFIG_PATH || './config.json', {encoding: 'utf8'})); | ||
if (config.sentryDsnNew) { | ||
Sentry.init({ dsn: config.sentryDsnNew }); | ||
} | ||
|
||
const port = process.env.PORT || 3000; | ||
|
||
const appProvider = new DefaultAppProvider(path.join(process.env.ANIMETA_FRONTEND_DIST_PATH, 'bundle.server.js')); | ||
const assets = JSON.parse(fs.readFileSync(path.join(process.env.ANIMETA_FRONTEND_DIST_PATH, 'assets.json'), {encoding: 'utf8'})); | ||
|
||
const server = createServer({ | ||
config, | ||
appProvider, | ||
getAssets: () => assets, | ||
staticDir: path.join(process.env.ANIMETA_FRONTEND_DIST_PATH, 'static'), | ||
}).listen(port, () => { | ||
console.log('Server running at port', port); | ||
}); | ||
|
||
function handleSignal(signal: string) { | ||
console.info(`Got ${signal}.`, new Date().toISOString()); | ||
server.close((err) => { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} else { | ||
process.exit(); | ||
} | ||
}); | ||
} | ||
|
||
process.on('SIGINT', handleSignal); | ||
process.on('SIGTERM', handleSignal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {createServer} from './frontend' | ||
export {evalCode, AppProvider, AppModule} from './AppProvider' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.