From afc1c0974526fbf5af14e979a0e54671c68dc880 Mon Sep 17 00:00:00 2001 From: claude Date: Tue, 10 Nov 2026 17:21:31 +0100 Subject: [PATCH] Initial commit: Dockerfile, docker-compose.yml, .env.example Co-Authored-By: Claude Opus 5.5 --- .env.example | 6 ++++++ .gitignore | 1 + Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 34 +++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8c4a236 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# cp .env.example .env +DOPBASE_REF=main +DOPBASE_PORT=8840 +DOPBASE_PUBLIC_URL=http://localhost:8840 +# DOPBASE_ROOT_EMAIL=admin@example.com +# DOPBASE_TRUSTED_PROXIES=172.16.0.0/12 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c375872 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +# Dopbase : build depuis les sources (le depot n'a pas de Dockerfile de prod). +# Etapes : clone -> UI Vue (bun) -> binaire Rust (UI embarquee) -> image runtime. + +ARG DOPBASE_REF=main + +# --- 1. Sources ------------------------------------------------------------- +FROM alpine/git AS src +ARG DOPBASE_REF +RUN git clone --depth 1 --branch "${DOPBASE_REF}" https://github.com/dopbase/dopbase.git /workspace + +# --- 2. Admin UI (Vite) ----------------------------------------------------- +FROM oven/bun:1 AS admin-ui +WORKDIR /workspace +COPY --from=src /workspace/package.json /workspace/bun.lock ./ +RUN bun install --frozen-lockfile +COPY --from=src /workspace/index.html /workspace/vite.config.ts /workspace/eslint.config.js ./ +COPY --from=src /workspace/tsconfig*.json ./ +COPY --from=src /workspace/config ./config +COPY --from=src /workspace/public ./public +COPY --from=src /workspace/src ./src +RUN bun run build:ui + +# --- 3. Binaire Rust (reprend la disposition de app/Dockerfile.test) -------- +FROM rust:1.98-bookworm AS builder +WORKDIR /workspace +COPY --from=src /workspace/app/Cargo.toml /workspace/app/Cargo.lock /workspace/app/build.rs ./app/ +COPY --from=src /workspace/app/src ./app/src +COPY --from=src /workspace/app/migrations ./app/migrations +COPY --from=admin-ui /workspace/dist ./dist +RUN cargo build --manifest-path app/Cargo.toml --release --locked + +# --- 4. Runtime ------------------------------------------------------------- +FROM debian:bookworm-slim +RUN apt-get update \ + && apt-get install --yes --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && useradd --system --uid 10001 --home-dir /data --shell /usr/sbin/nologin dopbase \ + && mkdir /data && chown dopbase:dopbase /data + +COPY --from=builder /workspace/app/target/release/dopbase /usr/local/bin/dopbase + +ENV DOPBASE_DATA_DIR=/data \ + DOPBASE_HOST=0.0.0.0 \ + DOPBASE_PORT=8840 + +USER dopbase +VOLUME ["/data"] +EXPOSE 8840 + +ENTRYPOINT ["dopbase"] +CMD ["server", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d1b8691 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +services: + dopbase: + build: + context: . + args: + # branche ou tag du depot dopbase/dopbase (ex: main, v0.1.10) + DOPBASE_REF: ${DOPBASE_REF:-main} + image: dopbase:local + container_name: dopbase + restart: unless-stopped + ports: + # 127.0.0.1 : accessible seulement depuis l'hote. Mettre un reverse proxy TLS devant + # pour tout acces reseau (recommande par la doc), ou retirer "127.0.0.1:" pour exposer. + - "127.0.0.1:${DOPBASE_PORT:-8840}:8840" + environment: + # URL que les clients utilisent (lien de setup, CLI). A adapter si reverse proxy. + DOPBASE_PUBLIC_URL: ${DOPBASE_PUBLIC_URL:-http://localhost:8840} + # Optionnel : cree root sans passer par le setup web (mot de passe genere, affiche UNE fois dans les logs). + # Laisser vide pour utiliser le lien de setup web affiche dans les logs au premier demarrage. + DOPBASE_ROOT_EMAIL: ${DOPBASE_ROOT_EMAIL:-} + # Si un reverse proxy tourne devant (IP/CIDR du proxy), pour des logs d'audit corrects. + DOPBASE_TRUSTED_PROXIES: ${DOPBASE_TRUSTED_PROXIES:-} + volumes: + # SQLite + master.key + backups (.dop) : a sauvegarder, la cle separement de la base. + - dopbase-data:/data + healthcheck: + test: ["CMD", "bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/8840"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 20s + +volumes: + dopbase-data: