diff --git a/.dockerignore b/.dockerignore index 5c05ee1..27002e6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -40,13 +40,5 @@ docs/ # Generated image variants (regenerated on startup from DB) priv/static/image_cache/ -# Mockup variants, digested copies, and converted formats. -# Only the source .webp files (no size suffix) should enter the build context — -# phx.digest creates its own hash-suffixed copies inside the builder. -priv/static/mockups/*-400* -priv/static/mockups/*-800* -priv/static/mockups/*-1200* -priv/static/mockups/*-thumb* -priv/static/mockups/*.avif -priv/static/mockups/*.jpg +# Mockup .gz files (phx.digest creates its own inside the builder) priv/static/mockups/*.gz diff --git a/assets/css/app-shop.css b/assets/css/app-shop.css index 1b91dae..4e64692 100644 --- a/assets/css/app-shop.css +++ b/assets/css/app-shop.css @@ -9,6 +9,7 @@ /* Only scan shop-specific files, not admin pages */ @source "../../lib/simpleshop_theme_web/live/shop_live"; @source "../../lib/simpleshop_theme_web/components/shop_components.ex"; +@source "../../lib/simpleshop_theme_web/components/shop_components"; @source "../../lib/simpleshop_theme_web/components/page_templates"; @source "../../lib/simpleshop_theme_web/components/layouts/shop.html.heex"; @source "../../lib/simpleshop_theme_web/components/layouts/shop_root.html.heex"; diff --git a/fly.toml b/fly.toml index 4f1b19d..bf11a25 100644 --- a/fly.toml +++ b/fly.toml @@ -1,50 +1,41 @@ -# fly.toml — Fly.io deployment configuration +# fly.toml app configuration file generated for simpleshop-theme on 2026-02-08T20:51:20Z +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. # -# Getting started: -# 1. Install flyctl: curl -L https://fly.io/install.sh | sh -# 2. Sign up / log in: fly auth login -# 3. Create the app: fly launch --no-deploy -# 4. Create a volume: fly volumes create simpleshop_data --size 1 -# 5. Set secrets: -# fly secrets set SECRET_KEY_BASE=$(mix phx.gen.secret) -# fly secrets set PHX_HOST=your-domain.com -# 6. Deploy: fly deploy -# 7. Open: fly open -app = "simpleshop-theme" -primary_region = "lhr" +app = 'simpleshop-theme' +primary_region = 'lhr' [build] - dockerfile = "Dockerfile" - -# SQLite needs a persistent volume — without this, your database is lost on every deploy. -[mounts] - source = "simpleshop_data" - destination = "/data" + dockerfile = 'Dockerfile' [env] - PHX_SERVER = "true" - DATABASE_PATH = "/data/simpleshop_theme.db" + DATABASE_PATH = '/data/simpleshop_theme.db' + PHX_SERVER = 'true' + +[[mounts]] + source = 'simpleshop_data' + destination = '/data' [http_service] internal_port = 4000 force_https = true - auto_stop_machines = "stop" + auto_stop_machines = 'stop' auto_start_machines = true min_machines_running = 0 [http_service.concurrency] - type = "connections" + type = 'connections' hard_limit = 1000 soft_limit = 1000 -[[http_service.checks]] - grace_period = "30s" - interval = "15s" - method = "GET" - timeout = "5s" - path = "/health" + [[http_service.checks]] + interval = '15s' + timeout = '5s' + grace_period = '30s' + method = 'GET' + path = '/health' [[vm]] - size = "shared-cpu-1x" - memory = "1gb" + size = 'shared-cpu-1x' + memory = '1gb' diff --git a/lib/simpleshop_theme/application.ex b/lib/simpleshop_theme/application.ex index 42ba64f..21abd2e 100644 --- a/lib/simpleshop_theme/application.ex +++ b/lib/simpleshop_theme/application.ex @@ -12,6 +12,8 @@ defmodule SimpleshopTheme.Application do SimpleshopTheme.Repo, {Ecto.Migrator, repos: Application.fetch_env!(:simpleshop_theme, :ecto_repos), skip: skip_migrations?()}, + # Seed default theme settings if none exist (first boot) + Supervisor.child_spec({Task, &SimpleshopTheme.Release.seed_defaults/0}, id: :seed_defaults), # Load encrypted secrets from DB into Application env {Task, &SimpleshopTheme.Secrets.load_all/0}, {DNSCluster, query: Application.get_env(:simpleshop_theme, :dns_cluster_query) || :ignore}, diff --git a/lib/simpleshop_theme/release.ex b/lib/simpleshop_theme/release.ex index 849b8b4..1f8d4c6 100644 --- a/lib/simpleshop_theme/release.ex +++ b/lib/simpleshop_theme/release.ex @@ -16,6 +16,25 @@ defmodule SimpleshopTheme.Release do end end + @doc """ + Seeds default theme settings if none exist. + + Called on every boot but only writes to the DB on first run + (when the settings table is empty). Safe to call repeatedly. + """ + def seed_defaults do + alias SimpleshopTheme.Settings + + case Settings.get_setting("theme_settings") do + nil -> + {:ok, _} = Settings.apply_preset(:studio) + :ok + + _exists -> + :ok + end + end + def rollback(repo, version) do load_app() {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version)) diff --git a/lib/simpleshop_theme_web/live/shop_live/product_show.ex b/lib/simpleshop_theme_web/live/shop_live/product_show.ex index 5c0f075..b7a1d42 100644 --- a/lib/simpleshop_theme_web/live/shop_live/product_show.ex +++ b/lib/simpleshop_theme_web/live/shop_live/product_show.ex @@ -61,6 +61,8 @@ defmodule SimpleshopThemeWeb.ShopLive.ProductShow do "/images/#{image_id}/variant/1200.webp" end + # Mock data uses base paths like "/mockups/product-1" — append size + format + defp image_src(_, "/mockups/" <> _ = url), do: "#{url}-1200.webp" defp image_src(_, url) when is_binary(url), do: url defp image_src(_, _), do: nil