fix production deployment: CSS, images and theme seeding

- Add @source for shop_components/ directory in app-shop.css (Tailwind
  wasn't scanning sub-modules after the refactor, dropping ~73 utilities)
- Remove overly aggressive .dockerignore rules that excluded mockup
  image variants needed by the responsive_image component
- Seed default theme settings on first boot via Release.seed_defaults/0
  in the supervision tree (seeds.exs doesn't run in releases)
- Fix PDP gallery images for mock data by appending -1200.webp to
  bare mockup base paths
- Update fly.toml format from fly launch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey 2026-02-08 23:42:56 +00:00
parent eb51385525
commit 865e3563b6
6 changed files with 47 additions and 40 deletions

View File

@ -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

View File

@ -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";

View File

@ -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"
interval = '15s'
timeout = '5s'
grace_period = '30s'
method = 'GET'
path = '/health'
[[vm]]
size = "shared-cpu-1x"
memory = "1gb"
size = 'shared-cpu-1x'
memory = '1gb'

View File

@ -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},

View File

@ -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))

View File

@ -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