From 1c847a824d19e583ca7dd596df4994ca181487c1 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Mon, 3 Aug 2026 20:26:02 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20Dockerfile=20=E2=86=92=20COPY=20pre-buil?= =?UTF-8?q?t=20binary=20(no=20network=20needed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker Desktop Windows blocks build network access. Instead of building V from source inside Docker, cross-compile Linux binary on host and COPY into minimal alpine image. --- Dockerfile | 16 +++++----------- docker_install.v | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9ad92f7..f848a54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,11 @@ -# ── Build: use official V container to compile ──────────────────────────── -FROM thevlang/vlang:alpine AS builder - -# Copy project source and build -WORKDIR /src -COPY . . -RUN git clone https://github.com/vlang/yaml.git /root/.vmodules/yaml -RUN v -prod -o /ntfy-bridge . - -# ── Runtime: minimal image ──────────────────────────────────────────────── +# ── Minimal Docker image for ntfy-bridge ────────────────────────────────── +# Binary is built on the host: v -os linux -o ntfy-bridge . FROM alpine:3.20 RUN apk add --no-cache ca-certificates tzdata curl -COPY --from=builder /ntfy-bridge /usr/local/bin/ntfy-bridge + +COPY ntfy-bridge /usr/local/bin/ntfy-bridge +RUN chmod +x /usr/local/bin/ntfy-bridge WORKDIR /etc/ntfy-bridge EXPOSE 9090 diff --git a/docker_install.v b/docker_install.v index 12fcdca..1905836 100644 --- a/docker_install.v +++ b/docker_install.v @@ -50,24 +50,20 @@ state: println(' Wrote: ${target_dir}/dashboard.html') } - // Copy Dockerfile and sources for build + // Copy Dockerfile and build Linux binary if os.exists('Dockerfile') { os.cp('Dockerfile', '${target_dir}/Dockerfile') or {} println(' Wrote: ${target_dir}/Dockerfile') } - // Copy V source files - src_files := ['main.v', 'server.v', 'config.v', 'log.v', 'ntfy.v', 'dedup.v', - 'docker_watcher.v', 'service.v', 'filter_outgoing.v', 'metrics.v', - 'docker_install.v', 'v.mod', 'dashboard.html', 'ntfy-bridge.example.yaml', - 'sources/event.v', 'sources/gitea.v', 'sources/uptime_kuma.v', - 'sources/docker.v', 'sources/generic.v', 'sources/cron.v', - 'sources/http_poll.v'] - for file in src_files { - if os.exists(file) { - target := '${target_dir}/${file}' - os.mkdir_all(os.dir(target)) or {} - os.cp(file, target) or {} - } + // Cross-compile Linux binary + println(' Building Linux binary (v -os linux)...') + build_result := os.execute('v -os linux -o ${target_dir}/ntfy-bridge .') + if build_result.exit_code != 0 { + println(' Warning: Could not cross-compile Linux binary.') + println(' ${build_result.output}') + println(' You will need a Linux binary named "ntfy-bridge" in ${target_dir}/') + } else { + println(' Built: ${target_dir}/ntfy-bridge') } // docker-compose.yml