瀏覽代碼

feat: add option for self-hosting via Docker (#1503)

Niko Heikkilä 5 年之前
父節點
當前提交
4369d88898
共有 5 個文件被更改,包括 59 次插入8 次删除
  1. 7 0
      .dockerignore
  2. 16 0
      Dockerfile
  3. 19 0
      README.md
  4. 9 0
      docker-compose.yml
  5. 8 8
      package.json

+ 7 - 0
.dockerignore

@@ -0,0 +1,7 @@
+*
+!public/
+!src/
+!.npmrc
+!package-lock.json
+!package.json
+!tsconfig.json

+ 16 - 0
Dockerfile

@@ -0,0 +1,16 @@
+FROM node:14-alpine AS build
+
+ENV NODE_ENV=production
+WORKDIR /usr/src/app
+
+COPY package.json package-lock.json ./
+RUN npm install
+
+COPY . .
+RUN npm run build:app
+
+FROM nginx:1.17-alpine
+
+COPY --from=build /usr/src/app/build /usr/share/nginx/html
+
+HEALTHCHECK CMD wget -q -O /dev/null http://localhost || exit 1

+ 19 - 0
README.md

@@ -48,6 +48,25 @@ git clone https://github.com/excalidraw/excalidraw.git
 | `npm run test:update` | Update test snapshots             |
 | `npm run test:code`   | Test for formatting with Prettier |
 
+### Docker Installation
+
+A production-ready version for deploying to e.g. Kubernetes or OpenShift can be built using Docker.
+
+#### Docker Compose
+
+```sh
+docker-compose up --build -d
+```
+
+#### Native Docker
+
+```sh
+docker build -t excalidraw/excalidraw .
+docker run --rm -dit --name excalidraw -p 5000:80 excalidraw/excalidraw:latest
+```
+
+After building the image and running the container, open <http://localhost:5000> to see the application.
+
 ## Contributing
 
 Pull requests are welcome. For major changes, please [open an issue](https://github.com/excalidraw/excalidraw/issues/new) first to discuss what you would like to change.

+ 9 - 0
docker-compose.yml

@@ -0,0 +1,9 @@
+version: "3"
+
+services:
+  excalidraw:
+    build: .
+    container_name: excalidraw
+    ports:
+      - "5000:80"
+    restart: on-failure

+ 8 - 8
package.json

@@ -31,16 +31,18 @@
     "react-dom": "16.13.1",
     "react-scripts": "3.4.1",
     "roughjs": "4.2.3",
-    "socket.io-client": "2.3.0"
-  },
-  "devDependencies": {
-    "@testing-library/jest-dom": "5.5.0",
-    "@testing-library/react": "10.0.3",
+    "socket.io-client": "2.3.0",
+    "node-sass": "4.14.0",
+    "typescript": "3.8.3",
     "@types/jest": "25.2.1",
     "@types/nanoid": "2.1.0",
     "@types/react": "16.9.34",
     "@types/react-dom": "16.9.6",
     "@types/socket.io-client": "1.4.32",
+    "@testing-library/jest-dom": "5.5.0",
+    "@testing-library/react": "10.0.3"
+  },
+  "devDependencies": {
     "asar": "3.0.3",
     "eslint": "6.8.0",
     "eslint-config-prettier": "6.11.0",
@@ -48,11 +50,9 @@
     "husky": "4.2.5",
     "jest-canvas-mock": "2.2.0",
     "lint-staged": "10.1.7",
-    "node-sass": "4.14.0",
     "pepjs": "0.5.2",
     "prettier": "2.0.5",
-    "rewire": "5.0.0",
-    "typescript": "3.8.3"
+    "rewire": "5.0.0"
   },
   "engines": {
     "node": ">=12.0.0"