Skip to content

Commit

Permalink
thuang-765-next-js
Browse files Browse the repository at this point in the history
  • Loading branch information
tihuan committed Feb 22, 2021
1 parent ffca067 commit 5b9a3ec
Show file tree
Hide file tree
Showing 67 changed files with 8,425 additions and 19,726 deletions.
60 changes: 35 additions & 25 deletions DEV_ENV.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: "3.8"

services:
database:
Expand Down Expand Up @@ -37,7 +37,7 @@ services:
depends_on:
- backend
ports:
- "8000:8000"
- "3000:3000"
command: ["./container_init.sh"]
environment:
- DEPLOYMENT_STAGE=dev
Expand Down
8 changes: 4 additions & 4 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ typings/
# configs
src/configs/configs.js

# gatsby files
.cache/
public

# Mac files
.DS_Store

# Yarn
yarn-error.log
.pnp/
.pnp.js

# Yarn Integrity file
.yarn-integrity

# Next.js
.next
13 changes: 13 additions & 0 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
plugins: [
[
"styled-components",
{
displayName: true,
preprocess: false,
ssr: true,
},
],
],
presets: ["next/babel"],
};
7 changes: 3 additions & 4 deletions frontend/container_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ ! -e ./node_modules ]; then
fi
ln -sf /opt/node_app/node_modules/* /opt/node_app/node_modules/.bin ./node_modules/.
if [ ! -z "$API_URL" ]; then
cat src/configs/rdev.js | envsubst > src/configs/configs.js
cat src/configs/rdev.js | envsubst >src/configs/configs.js
else
cp src/configs/local.js src/configs/configs.js
fi
Expand All @@ -21,8 +21,7 @@ fi

# Build and run without dev mode in remote dev env.
if [ "${DEPLOYMENT_STAGE}" == "dev" ]; then
exec gatsby develop --host 0.0.0.0
exec npm run dev
else
npm run build
exec gatsby serve --host 0.0.0.0
exec npm run build-and-start-prod -p 9000
fi
44 changes: 0 additions & 44 deletions frontend/gatsby-config.js

This file was deleted.

14 changes: 0 additions & 14 deletions frontend/gatsby-node.js

This file was deleted.

2 changes: 2 additions & 0 deletions frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
55 changes: 55 additions & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const withImages = require("next-images");

const configs = require(__dirname + "/src/configs/configs.js");
const nodeEnv = require(__dirname + "/src/common/constants/nodeEnv.js");

const { createSecureHeaders } = require("next-secure-headers");

const isProdBuild = process.env.NODE_ENV === nodeEnv.PRODUCTION;

const SCRIPT_SRC = ["'self'"];

module.exports = withImages({
future: { webpack5: true },

headers() {
return [
{
headers: createSecureHeaders({
contentSecurityPolicy: {
directives: {
baseUri: "self",
connectSrc: [
"'self'",
"sentry.prod.si.czi.technology",
configs.API_URL,
],
defaultSrc: ["'self'"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
formAction: "self",
frameAncestors: ["'none'"],
imgSrc: ["'self'", "data:"],
mediaSrc: ["self"],
objectSrc: ["'none'"],
reportURI:
configs.SENTRY_DEPLOYMENT_ENVIRONMENT &&
"https://sentry.prod.si.czi.technology/api/167/security/?sentry_key=0432f3b3ceba4bc08d28dfb61fa29707&sentry_environment=" +
configs.SENTRY_DEPLOYMENT_ENVIRONMENT,
scriptSrc: isProdBuild
? SCRIPT_SRC
: [...SCRIPT_SRC, "'unsafe-eval'"],
styleSrc: [
"'self'",
"'unsafe-inline'",
"https://fonts.googleapis.com",
],
upgradeInsecureRequests: true,
workerSrc: true,
},
},
}),
source: "/(.*)",
},
];
},
});
Loading

0 comments on commit 5b9a3ec

Please sign in to comment.