Skip to content

Dockerizing draft-js #1

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down
10 changes: 9 additions & 1 deletion website/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down