Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr committed Apr 29, 2024
1 parent d3efdba commit 9390ee8
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 886 deletions.
11 changes: 0 additions & 11 deletions .dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ deploy.env

.nx/cache
.tmp
tmp
23 changes: 0 additions & 23 deletions Dockerfile

This file was deleted.

19 changes: 8 additions & 11 deletions apps/service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# This file is generated by Nx.
#
# Build the docker image with `npx nx docker-build service`.
# Tip: Modify "docker-build" options in project.json to change docker build args.
#
# Run the container with `docker run -p 3000:3000 -t service`.
FROM docker.io/node:20-alpine
FROM --platform=linux/amd64 docker.io/node:20-alpine

ENV HOST=0.0.0.0
ENV PORT=3000
ENV PORT=3333

WORKDIR /app

RUN addgroup --system service && \
adduser --system -G service service
RUN addgroup --system service && adduser --system -G service service

# Needed by @fastify/secure-session
RUN npm i sodium-native@^4.0.0

COPY dist/apps/service service

RUN chown -R service:service .

CMD [ "node", "service" ]
CMD [ "node", "service/app.js" ]
2 changes: 1 addition & 1 deletion apps/service/api/serverless.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import init from '../dist';
import init from '../app';

export default async (req, res) => {
const app = init();
Expand Down
25 changes: 22 additions & 3 deletions apps/service/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"defaultConfiguration": "production",
"options": {
"platform": "node",
"target": "node20",
"target": "node18",
"outputPath": "dist/apps/service",
"format": ["cjs"],
"bundle": true,
"deleteOutputPath": true,
"main": "apps/service/src/main.ts",
"main": "apps/service/src/app.ts",
"tsConfig": "apps/service/tsconfig.app.json",
"generatePackageJson": false,
"external": ["sodium-native"],
"esbuildOptions": {
"sourcemap": true,
"outExtension": {
Expand Down Expand Up @@ -68,6 +69,22 @@
"production": {
"thirdParty": true,
"minify": true
},
"vercel": {
"thirdParty": true,
"minify": true,
"assets": [
{
"glob": "**/*",
"input": "apps/service/public",
"output": "public"
},
{
"glob": "**/*",
"input": "apps/service/api",
"output": "api"
}
]
}
}
},
Expand All @@ -79,7 +96,9 @@
"runBuildTargetDependencies": true,
"buildTargetOptions": {
"progress": true
}
},
"args": ["--listen"],
"debounce": 1000
},
"configurations": {
"development": {
Expand Down
15 changes: 15 additions & 0 deletions apps/service/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,19 @@ function init() {
return app;
}

// If called directly i.e. "node app"
if (require.main === module || process.argv.includes('--listen')) {
const app = init();
const host = process.env.HOST ?? '0.0.0.0';
const port = process.env.PORT ? Number(process.env.PORT) : 3333;

app.listen({ host, port }, (err) => {
if (err) {
app.log.fatal(err);
process.exit(1);
}
});
}

// Required as a module => executed on vercel / other serverless platform
export default init;
15 changes: 0 additions & 15 deletions apps/service/src/main.ts

This file was deleted.

3 changes: 2 additions & 1 deletion apps/service/vercel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"buildCommand": "yarn add sodium-native@^4.0.0",
"buildCommand": "yarn nx build service -c vercel && yarn add sodium-native@^4.0.0",
"outputDirectory": "dist/apps/service",
"rewrites": [
{
"source": "/(.*)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lazy } from 'react';

const ReportsChart = lazy(() => import(/* webpackChunkName: "ReportsChart" */ './ReportsChart'));
const ReportsChart = lazy(() => import('./ReportsChart'));

export default ReportsChart;
8 changes: 4 additions & 4 deletions apps/website/src/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { lazy } from 'react';

export { default as HomePage } from './HomePage';
export const CreateProjectPage = lazy(() => import(/* webpackChunkName: "CreateProjectPage" */ './CreateProjectPage'));
export const ReportPage = lazy(() => import(/* webpackChunkName: "ReportPage" */ './ReportPage'));
export const ReportsPage = lazy(() => import(/* webpackChunkName: "ReportsPage" */ './ReportsPage'));
export const LoginPage = lazy(() => import(/* webpackChunkName: "LoginPage" */ './LoginPage'));
export const CreateProjectPage = lazy(() => import('./CreateProjectPage'));
export const ReportPage = lazy(() => import('./ReportPage'));
export const ReportsPage = lazy(() => import('./ReportsPage'));
export const LoginPage = lazy(() => import('./LoginPage'));
49 changes: 0 additions & 49 deletions apps/website/webpack/webpack.base.config.js

This file was deleted.

16 changes: 0 additions & 16 deletions apps/website/webpack/webpack.config.js

This file was deleted.

23 changes: 0 additions & 23 deletions apps/website/webpack/webpack.dev.config.js

This file was deleted.

32 changes: 0 additions & 32 deletions apps/website/webpack/webpack.prod.config.js

This file was deleted.

16 changes: 0 additions & 16 deletions dev-utils/getJestConfig.ts

This file was deleted.

28 changes: 0 additions & 28 deletions docker-compose.dev.yml

This file was deleted.

8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
"@nx/react": "^18.3.3",
"@nx/vite": "18.3.3",
"@nx/web": "18.3.3",
"@swc-node/register": "~1.8.0",
"@swc/cli": "~0.1.62",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@testing-library/react": "14.0.0",
"@types/jest": "^29.5.1",
"@types/jest-when": "^3.5.2",
"@types/node": "18.16.9",
Expand All @@ -37,10 +32,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-when": "^3.5.2",
Expand Down
Loading

0 comments on commit 9390ee8

Please sign in to comment.