diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..9ff5ec2e64 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:latest + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app +COPY package.json /usr/src/app/ + +RUN npm install --silent + +RUN cd website && pwd && npm install +RUN pwd +RUN ls -l +RUN npm run build + +WORKDIR /usr/src/app/website +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/README.md b/README.md index 5b1d545809..4879d5d52a 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,39 @@ Draft.js is used in production on Facebook, including status and comment inputs, [Notes](https://www.facebook.com/notes/), and [messenger.com](https://www.messenger.com). +## Build and run website + +The first time, get all the dependencies loaded via +``` +npm install +``` + +Then, run the server via + +``` +npm start +Open http://localhost:8080/draft-js/index.html +``` + +## How dockerize this project? + +Create Dockerfile for this project and try it on [Codefresh](https://codefresh.io/). +``` +FROM node:latest + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app +COPY . /usr/src/app +COPY package.json /usr/src/app/ + +RUN npm install --silent +RUN cd website && pwd && npm install +RUN npm run build + +WORKDIR /usr/src/app/website +CMD [ "npm", "start" ] +``` + ## Discussion and Support Join our [Slack team](https://draftjs.herokuapp.com)! diff --git a/website/server/server.js b/website/server/server.js index 7f70d5a38e..4b1488a6fb 100644 --- a/website/server/server.js +++ b/website/server/server.js @@ -44,7 +44,15 @@ var app = connect() .use(function(req, res, next) { // convert all the md files on every request. This is not optimal // but fast enough that we don't really need to care right now. - convert(); + if(req.method =='GET') { + if(req.url == "/") { + var path = 'draft-js/index.html'; + res.writeHead(302, {'Location': path}); + res.end(); + } + } + + convert(); next(); }) .use(reactMiddleware.provide(buildOptions))