Spaces:
Running
Running
Create Dockerfile
Browse files- Dockerfile +57 -0
Dockerfile
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# --- build stage -------------------------------------------------------------
|
2 |
+
FROM node:20-bullseye-slim AS builder
|
3 |
+
|
4 |
+
ARG EXCALIDRAW_REPO=https://github.com/excalidraw/excalidraw.git
|
5 |
+
ARG EXCALIDRAW_ROOM_REPO=https://github.com/excalidraw/excalidraw-room.git
|
6 |
+
ARG EXCALIDRAW_STORAGE_REPO=https://github.com/excalidraw/excalidraw-storage-backend.git
|
7 |
+
|
8 |
+
# URLs the client has to call once deployed
|
9 |
+
ENV REACT_APP_WS_SERVER_URL=/room
|
10 |
+
ENV REACT_APP_HTTP_STORAGE_BACKEND_URL=/api
|
11 |
+
|
12 |
+
RUN apt-get update -y \
|
13 |
+
&& apt-get install -y git
|
14 |
+
|
15 |
+
# --- clone & build the React client -----------------------------------------
|
16 |
+
RUN git clone --depth 1 $EXCALIDRAW_REPO /opt/excalidraw
|
17 |
+
WORKDIR /opt/excalidraw
|
18 |
+
RUN corepack enable && yarn --frozen-lockfile
|
19 |
+
RUN yarn build \
|
20 |
+
--mode=production \
|
21 |
+
--env REACT_APP_WS_SERVER_URL=$REACT_APP_WS_SERVER_URL \
|
22 |
+
--env REACT_APP_HTTP_STORAGE_BACKEND_URL=$REACT_APP_HTTP_STORAGE_BACKEND_URL
|
23 |
+
|
24 |
+
# --- clone servers (no build step needed) ------------------------------------
|
25 |
+
RUN git clone --depth 1 $EXCALIDRAW_ROOM_REPO /opt/room
|
26 |
+
RUN git clone --depth 1 $EXCALIDRAW_STORAGE_REPO /opt/storage
|
27 |
+
|
28 |
+
WORKDIR /opt/room
|
29 |
+
RUN yarn --production
|
30 |
+
WORKDIR /opt/storage
|
31 |
+
RUN yarn --production
|
32 |
+
|
33 |
+
# --- runtime stage -----------------------------------------------------------
|
34 |
+
FROM node:20-bullseye-slim
|
35 |
+
|
36 |
+
ENV PORT=7860
|
37 |
+
ENV ROOM_PORT=5001
|
38 |
+
ENV STORAGE_PORT=5002
|
39 |
+
ENV REDIS_PORT=6379
|
40 |
+
|
41 |
+
# install nginx, redis & supervisor
|
42 |
+
RUN apt-get update -y \
|
43 |
+
&& apt-get install -y nginx redis-server supervisor \
|
44 |
+
&& rm -rf /var/lib/apt/lists/* \
|
45 |
+
&& mkdir -p /var/log/supervisor
|
46 |
+
|
47 |
+
# copy artifacts from builder
|
48 |
+
COPY --from=builder /opt /opt
|
49 |
+
|
50 |
+
# nginx routing: / → client, /room → WS server, /api → storage
|
51 |
+
COPY nginx.conf /etc/nginx/conf.d/excalidraw.conf
|
52 |
+
|
53 |
+
# supervisor keeps every service alive
|
54 |
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
55 |
+
|
56 |
+
EXPOSE ${PORT}
|
57 |
+
CMD ["/usr/bin/supervisord","-n"]
|