Skip to content

Commit

Permalink
Merge pull request #296 from groodt/groodt-nextjs-folderstructure
Browse files Browse the repository at this point in the history
Refactor folder structure
  • Loading branch information
captainsafia authored Jun 10, 2020
2 parents 3a7db09 + 38c9827 commit c03d5bb
Show file tree
Hide file tree
Showing 46 changed files with 25 additions and 24 deletions.
31 changes: 14 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,21 @@
##################################
FROM node:14 as build

RUN mkdir -p /opt/build;
RUN mkdir -p /opt/build

WORKDIR /opt/build

# Would be a bit simpler if the code was inside a top-level src folder
COPY ./backend ./backend
COPY ./components ./components
COPY ./pages ./pages
COPY ./public ./public
COPY ./shims ./shims
COPY ./transforms ./transforms
COPY ./src ./src
COPY [ \
"babel.config.js", \
"frontend.js", \
"next.config.js", \
"package.json", \
"theme.js", \
"yarn.lock", \
"./" \
]

RUN yarn install \
&& yarn build
RUN yarn install && \
yarn build

##################################
# Dependencies
Expand All @@ -40,15 +32,21 @@ RUN DEBIAN_FRONTEND=noninteractive \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev
librsvg2-dev && \
\
rm -rf /var/lib/apt/lists/*

ENV NODE_ENV='production'

RUN mkdir -p /opt/build;
RUN mkdir -p /opt/build

WORKDIR /opt/build

COPY --from=build [ "/opt/build/package.json", "/opt/build/yarn.lock", "./" ]
COPY --from=build [ \
"/opt/build/package.json", \
"/opt/build/yarn.lock", \
"./" \
]

RUN yarn install --production=true

Expand All @@ -64,12 +62,11 @@ RUN chmod +x /tini

ENV NODE_ENV='production'

RUN mkdir -p /opt/app;
RUN mkdir -p /opt/app

WORKDIR /opt/app

COPY --from=build /opt/build/.next /opt/app/.next
COPY --from=build /opt/build/frontend.js /opt/app/
COPY --from=build /opt/build/lib /opt/app/lib
COPY --from=build /opt/build/public /opt/app/public
COPY --from=dependencies /opt/build/node_modules /opt/app/node_modules
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
"start": "NODE_ENV=production node lib/index.js",
"build": "npm run build:all",
"build:frontend-for-production": "next build",
"build:server": "babel backend -d lib",
"build:server": "babel src -d lib",
"build:all": "npm run build:server && npm run build:frontend-for-production",
"prepublishOnly": "npm run build:all",
"test": "jest"
},
"bin": {
"commuter": "bin.js"
"commuter": "lib/bin.js"
},
"jest": {
"testRegex": "tests"
},
"repository": "nteract/nteract",
"keywords": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin.js β†’ src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

process.env.NODE_ENV = "production";

require("./lib/index.js");
require("./index.js");
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion frontend.js β†’ src/frontend.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Note: this module must remain compatible with the ECMAScript version of the
// Server as it does _not_ get transpiled
const next = require("next");
const path = require("path");

const dev = process.env.NODE_ENV !== "production" && !process.env.NOW;

function createNextApp() {
const app = next({ dev, dir: __dirname });
const app = next({ dev, dir: path.join(__dirname, "..") });
const handle = app.getRequestHandler();

return {
Expand Down
2 changes: 1 addition & 1 deletion backend/index.js β†’ src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
const log = require("log");

const createServer = require("./server");
const createServer = require("./backend/server");

createServer()
.then(server => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
const isDir = require("./../backend/content-providers/s3/contents").isDir;
const isDir = require("./../src/backend/content-providers/s3/contents").isDir;

describe("Routes util tests", () => {
test("returns isDir true", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/s3test.js β†’ tests/s3test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
jest.mock("aws-sdk/clients/s3");
const awsMock = require("aws-sdk/clients/s3");

const s3Service = require("./../backend/content-providers/s3/s3");
const s3Service = require("./../src/backend/content-providers/s3/s3");

describe("Test S3 service", () => {
test("getObject returns notebook content", done => {
Expand Down

0 comments on commit c03d5bb

Please sign in to comment.