Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor folder structure #296

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
2 changes: 1 addition & 1 deletion frontend.js → src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const next = require("next");
const dev = process.env.NODE_ENV !== "production" && !process.env.NOW;

function createNextApp() {
const app = next({ dev, dir: __dirname });
const app = next({ dev, dir: `${__dirname}/../` });
groodt marked this conversation as resolved.
Show resolved Hide resolved
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.
2 changes: 1 addition & 1 deletion __tests__/routesUtil-spec.js → tests/routesUtil-spec.js
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