MyExcalidraw / Dockerfile
MoiMoi-01's picture
Create Dockerfile
b66f252 verified
# --- build stage -------------------------------------------------------------
FROM node:20-bullseye-slim AS builder
ARG EXCALIDRAW_REPO=https://github.com/excalidraw/excalidraw.git
ARG EXCALIDRAW_ROOM_REPO=https://github.com/excalidraw/excalidraw-room.git
ARG EXCALIDRAW_STORAGE_REPO=https://github.com/excalidraw/excalidraw-storage-backend.git
# URLs the client has to call once deployed
ENV REACT_APP_WS_SERVER_URL=/room
ENV REACT_APP_HTTP_STORAGE_BACKEND_URL=/api
RUN apt-get update -y \
&& apt-get install -y git
# --- clone & build the React client -----------------------------------------
RUN git clone --depth 1 $EXCALIDRAW_REPO /opt/excalidraw
WORKDIR /opt/excalidraw
RUN corepack enable && yarn --frozen-lockfile
RUN yarn build \
--mode=production \
--env REACT_APP_WS_SERVER_URL=$REACT_APP_WS_SERVER_URL \
--env REACT_APP_HTTP_STORAGE_BACKEND_URL=$REACT_APP_HTTP_STORAGE_BACKEND_URL
# --- clone servers (no build step needed) ------------------------------------
RUN git clone --depth 1 $EXCALIDRAW_ROOM_REPO /opt/room
RUN git clone --depth 1 $EXCALIDRAW_STORAGE_REPO /opt/storage
WORKDIR /opt/room
RUN yarn --production
WORKDIR /opt/storage
RUN yarn --production
# --- runtime stage -----------------------------------------------------------
FROM node:20-bullseye-slim
ENV PORT=7860
ENV ROOM_PORT=5001
ENV STORAGE_PORT=5002
ENV REDIS_PORT=6379
# install nginx, redis & supervisor
RUN apt-get update -y \
&& apt-get install -y nginx redis-server supervisor \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/log/supervisor
# copy artifacts from builder
COPY --from=builder /opt /opt
# nginx routing: / β†’ client, /room β†’ WS server, /api β†’ storage
COPY nginx.conf /etc/nginx/conf.d/excalidraw.conf
# supervisor keeps every service alive
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE ${PORT}
CMD ["/usr/bin/supervisord","-n"]