excalidraw docker 部署

excalidraw docker 部署

  • Dockerfile 文件
FROM node:14-alpine AS build

WORKDIR /opt/node_app

COPY package.json yarn.lock ./
RUN yarn --ignore-optional

ARG NODE_ENV=production

COPY . .
RUN yarn build:app:docker

FROM nginx:1.21-alpine

COPY --from=build /opt/node_app/build /usr/share/nginx/html

HEALTHCHECK CMD wget -q -O /dev/null http://localhost || exit 1

  • 构建命令
docker build -t excalidraw/excalidraw .
  • docker-compose.yml 文件
version: "3.8"

services:
  excalidraw:
    image: excalidraw/excalidraw
    container_name: excalidraw
    ports:
      - "8080:80"
    restart: on-failure
  • docker-compose 启动
docker-compose up -d
  • nginx 配置
upstream excalidraw.weihongbin {
    server 127.0.0.1:8080;
}

map $http_upgrade $connection_upgrade {
    default Upgrade;
    '' close;
}

server {
    listen 443 ssl http2;
    server_name excalidraw.weihongbin.com;
    ssl_certificate /opt/tools/homeland-docker/shared/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/excalidraw.weihongbin.com/excalidraw.weihongbin.com.pem;
    ssl_certificate_key /opt/tools/homeland-docker/shared/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/excalidraw.weihongbin.com/excalidraw.weihongbin.com.key;

    location / {
        sendfile off;
        proxy_pass http://excalidraw.weihongbin;
        proxy_redirect default;
        proxy_http_version 1.1;

        # Required for Jenkins websocket agents
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_max_temp_file_size 0;

        #this is the maximum upload size
        client_max_body_size 1024m;
        client_body_buffer_size 128k;

        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffering off;
        proxy_request_buffering off; # Required for HTTP CLI commands
        proxy_set_header Connection ""; # Clear for keepalive
    }
}

server {
    listen 80;
    server_name excalidraw.weihongbin.com;
    return 301 https://$server_name$request_uri;
}
  • 相关链接

https://github.com/excalidraw/excalidraw