Add dockerfiles to webapp and webpeer

This commit is contained in:
vorotamoroz
2026-04-02 10:33:13 +01:00
parent 2e3e106fb2
commit 6ce724afb4
4 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
# syntax=docker/dockerfile:1
#
# Self-hosted LiveSync WebApp — Docker image
# Browser-based vault sync using the FileSystem API, served by nginx.
#
# Build (from the repository root):
# docker build -f src/apps/webapp/Dockerfile -t livesync-webapp .
#
# Run:
# docker run --rm -p 8080:80 livesync-webapp
# Then open http://localhost:8080/webapp.html in Chrome/Edge 86+.
#
# Notes:
# - This image serves purely static files; no server-side code is involved.
# - The FileSystem API is a browser feature and requires Chrome/Edge 86+ or
# Safari 15.2+ (limited). Firefox is not supported.
# - CouchDB / S3 connections are made directly from the browser; the container
# only serves HTML/JS/CSS assets.
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1 — builder
# Full Node.js environment to install dependencies and build the Vite bundle.
# ─────────────────────────────────────────────────────────────────────────────
FROM node:22-slim AS builder
WORKDIR /build
# Install workspace dependencies (all apps share the root package.json)
COPY package.json ./
RUN npm install
# Copy the full source tree and build the WebApp bundle
COPY . .
RUN cd src/apps/webapp && npm run build
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2 — runtime
# Minimal nginx image that serves the static build output.
# ─────────────────────────────────────────────────────────────────────────────
FROM nginx:stable-alpine
# Remove the default nginx welcome page
RUN rm -rf /usr/share/nginx/html/*
# Copy the built static assets
COPY --from=builder /build/src/apps/webapp/dist /usr/share/nginx/html
# Redirect the root to webapp.html so the app loads on first visit
RUN printf 'server {\n\
listen 80;\n\
root /usr/share/nginx/html;\n\
index webapp.html;\n\
location / {\n\
try_files $uri $uri/ =404;\n\
}\n\
}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 80

View File

@@ -7,6 +7,8 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:docker": "docker build -f Dockerfile -t livesync-webapp ../../..",
"run:docker": "docker run -p 8002:80 livesync-webapp",
"preview": "vite preview"
},
"dependencies": {},

View File

@@ -0,0 +1,57 @@
# syntax=docker/dockerfile:1
#
# Self-hosted LiveSync WebPeer — Docker image
# Browser-based P2P peer daemon served by nginx.
#
# Build (from the repository root):
# docker build -f src/apps/webpeer/Dockerfile -t livesync-webpeer .
#
# Run:
# docker run --rm -p 8081:80 livesync-webpeer
# Then open http://localhost:8081/ in any modern browser.
#
# What is WebPeer?
# WebPeer acts as a pseudo P2P peer that runs entirely in the browser.
# It can replace a CouchDB remote server by replying to sync requests from
# other Self-hosted LiveSync instances over the WebRTC P2P channel.
#
# P2P (WebRTC) networking notes
# ─────────────────────────────
# WebRTC connections are initiated by the *browser* visiting this page, not by
# the nginx container itself. Therefore the Docker network mode of this
# container has NO effect on WebRTC connectivity.
# Simply publish port 80 (as above) and the browser handles all ICE/STUN/TURN
# negotiation on its own.
#
# If the browser is running inside another container or a restricted network,
# configuring a TURN server in the WebPeer settings is recommended.
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1 — builder
# Full Node.js environment to install dependencies and build the Vite bundle.
# ─────────────────────────────────────────────────────────────────────────────
FROM node:22-slim AS builder
WORKDIR /build
# Install workspace dependencies (all apps share the root package.json)
COPY package.json ./
RUN npm install
# Copy the full source tree and build the WebPeer bundle
COPY . .
RUN cd src/apps/webpeer && npm run build
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2 — runtime
# Minimal nginx image that serves the static build output.
# ─────────────────────────────────────────────────────────────────────────────
FROM nginx:stable-alpine
# Remove the default nginx welcome page
RUN rm -rf /usr/share/nginx/html/*
# Copy the built static assets
COPY --from=builder /build/src/apps/webpeer/dist /usr/share/nginx/html
EXPOSE 80

View File

@@ -6,6 +6,8 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:docker": "docker build -f Dockerfile -t livesync-webpeer ../../..",
"run:docker": "docker run -p 8001:80 livesync-webpeer",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
},