-- =====================================================================
-- Migration 070: Speed up / stabilize AmneziaWG 2.0 (awg2) installation
--
-- Issue #50: the first install of awg2 frequently failed with
-- "Invalid server response". Root cause: the install script ran
-- `docker build --no-cache` every time, forcing a full recompile of the
-- amneziawg-go Go sources on each attempt. That build can take several
-- minutes, exceeding the web request timeout, so the browser received a
-- truncated (non-JSON) response. On retry the work from the first attempt
-- had already produced the image/config, so it "magically" succeeded.
--
-- Dropping `--no-cache` lets Docker reuse cached layers, making installs
-- (and especially retries) fast and idempotent. The sources are pinned via
-- `git clone --depth=1`, so a cached build is the desired behaviour.
-- =====================================================================

UPDATE protocols
SET install_script = REPLACE(install_script, 'docker build --no-cache -t amnezia-awg2', 'docker build -t amnezia-awg2')
WHERE slug = 'awg2'
  AND install_script LIKE '%docker build --no-cache -t amnezia-awg2%';
