Spaces:
Paused
Paused
File size: 2,053 Bytes
b66f252 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# --- 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"]
|