~electric/shop-oregon-local

1b572765210b340b03fe45b9af9dad065447a7a4 — Micah D 5 months ago 34ba424
Deployment fixes
M README.md => README.md +3 -9
@@ 1,18 1,12 @@
# ShopLocal

To start your Phoenix server:
Simple website to search some localshops

To start the server:

  * Install dependencies with `mix deps.get`
  * Start Phoenix endpoint with `mix phx.server`

Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.

Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).

## Learn more

  * Official website: https://www.phoenixframework.org/
  * Guides: https://hexdocs.pm/phoenix/overview.html
  * Docs: https://hexdocs.pm/phoenix
  * Forum: https://elixirforum.com/c/phoenix-forum
  * Source: https://github.com/phoenixframework/phoenix

M config/prod.exs => config/prod.exs +8 -1
@@ 10,7 10,14 @@ use Mix.Config
# which you should run after static files are built and
# before starting your production server.
config :shop_local, ShopLocalWeb.Endpoint,
  url: [host: "example.com", port: 80],
  url: [host: "shop-local.dvyld.com", port: 80],
  https: [
    port: 443,
    cipher_suite: :strong,
    keyfile: '/etc/letsencrypt/live/shop-local.dvyld.com/privkey.pem',
    certfile: '/etc/letsencrypt/live/shop-local.dvyld.com/fullchain.pem',
    transport_options: [socket_opts: [:inet6]]
  ],
  cache_static_manifest: "priv/static/cache_manifest.json"

# Do not print debug messages in production

M config/prod.secret.exs => config/prod.secret.exs +1 -1
@@ 24,7 24,7 @@ config :shop_local, :basic_auth, username: System.get_env("DASH_USER"), password
# If you are doing OTP releases, you need to instruct Phoenix
# to start each relevant endpoint:
#
#     config :shop_local, ShopLocalWeb.Endpoint, server: true
config :shop_local, ShopLocalWeb.Endpoint, server: true
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.

A deploy.sh => deploy.sh +17 -0
@@ 0,0 1,17 @@
mix phx.digest && \
echo "Syncing $1 to $2" && \
rsync -r \
      --exclude='node_modules' \
      --exclude='package*.json' \
      --exclude='*.lock' \
      --exclude='*.spec.*' \
      --exclude='.*' \
      --exclude='/_build' \
      --exclude='/cover' \
      --exclude='/deps' \
      --exclude='/doc' \
      --exclude='/.fetch' \
      --exclude='erl_crash.dump' \
      --exclude='*.ez' \
      --exclude='shop_local-*.tar' \
      $1 $2

M lib/shop_local/clothing_tree_search_provider.ex => lib/shop_local/clothing_tree_search_provider.ex +1 -1
@@ 23,7 23,7 @@ defmodule ShopLocal.ClothingTreeSearchProvider do
                    end

                      %{
                        provider: "Clothing Tree",
                        provider: "Clothes Tree",
                        name: name,
                        desc: "",
                        price: price,

A lib/shop_local_web/controllers/certbot_controller.ex => lib/shop_local_web/controllers/certbot_controller.ex +20 -0
@@ 0,0 1,20 @@
defmodule ShopLocalWeb.CertbotController do

  use ShopLocalWeb, :controller
  def certbot(conn, %{"challenge" => file_name}) do
    base_path = System.get_env("ACME_CHALLENGE_DIR")
    safe_file_name = Path.basename(file_name)

    case File.read(Path.join([base_path, "/.well-known/acme-challenge", safe_file_name])) do
      {:ok, content} ->
        send_resp(conn, 200, content)
      _ ->
        send_resp(conn, 200, "Not Valid")
    end
  end

  def certbot(conn, _) do
    send_resp(conn, 200, "Not valid")
  end

end

M lib/shop_local_web/endpoint.ex => lib/shop_local_web/endpoint.ex +0 -1
@@ 23,7 23,6 @@ defmodule ShopLocalWeb.Endpoint do
  plug Plug.Static,
    at: "/",
    from: :shop_local,
    gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt)

  # Code reloading can be explicitly enabled under the

M lib/shop_local_web/router.ex => lib/shop_local_web/router.ex +4 -0
@@ 26,6 26,10 @@ defmodule ShopLocalWeb.Router do
    post "/", PageController, :search
  end

  scope "/.well-known/acme-challenge", ShopLocalWeb do
    get "/:challenge", CertbotController, :certbot
  end

  # Other scopes may use custom stacks.
  # scope "/api", ShopLocalWeb do
  #   pipe_through :api

M lib/shop_local_web/templates/layout/app.html.eex => lib/shop_local_web/templates/layout/app.html.eex +1 -6
@@ 4,16 4,11 @@
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>ShopLocal</title>
    <title>Shop Local</title>
    <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
    <script defer type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
  </head>
  <body>
    <header>
      <section class="container">
        <h1>Shop Local</h2>
      </section>
    </header>
    <main role="main" class="container">
      <p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
      <p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>

M lib/shop_local_web/templates/page/index.html.eex => lib/shop_local_web/templates/page/index.html.eex +18 -12
@@ 1,5 1,5 @@
<section class="phx-hero">
  <h3></h3>
  <h3>Shop Local</h3>
  <%= form_for @conn, Routes.page_path(@conn, :search), fn f -> %>
    <%= text_input f, :search, placeholder: "What are you looking for?" %>
    <%= submit "Search" %>


@@ 40,13 40,7 @@
    <h2>Regions</h2>
    <ul>
      <li>
        <a href="https://hexdocs.pm/phoenix/overview.html">Guides &amp; Docs</a>
      </li>
      <li>
        <a href="https://github.com/phoenixframework/phoenix">Source</a>
      </li>
      <li>
        <a href="https://github.com/phoenixframework/phoenix/blob/v1.5/CHANGELOG.md">v1.5 Changelog</a>
        <a href="https://www.visitcorvallis.com/shopping">Corvallis</a>
      </li>
    </ul>
  </article>


@@ 54,16 48,28 @@
    <h2>Stores</h2>
    <ul>
      <li>
        <a href="https://elixirforum.com/c/phoenix-forum">Forum</a>
        <a href="https://pegasusgames.com">Pegasus Games</a>
      </li>
      <li>
        <a href="https://www.clothes-tree.com/">The Clothes Tree</a>
      </li>
      <li>
        <a href="https://www.thetoyfactory.us">The Toy Factory</a>
      </li>
      <li>
        <a href="https://www.restylecorvallis.com/shop">Restyle Corvallis</a>
      </li>
      <li>
        <a href="https://burstschocolates.com/">Bursts Chocolates</a>
      </li>
      <li>
        <a href="https://webchat.freenode.net/?channels=elixir-lang">#elixir-lang on Freenode IRC</a>
        <a href="https://conundrum.house/">Conundrum House</a>
      </li>
      <li>
        <a href="https://twitter.com/elixirphoenix">Twitter @elixirphoenix</a>
        <a href="https://oregoncoffeeandtea.com/">Oregon Coffee &amp; Tea</a>
      </li>
      <li>
        <a href="https://elixir-slackin.herokuapp.com/">Elixir on Slack</a>
        <a href="http://www.robnettshardware.com/">Robnett's Hardware</a>
      </li>
    </ul>
  </article>

M run_prod.sh => run_prod.sh +2 -7
@@ 1,9 1,4 @@
# Initial setup
mix deps.get --only prod
MIX_ENV=prod mix compile

# Compile assets
mix phx.digest

mix deps.get --only prod && PORT=80 MIX_ENV=prod mix release && \
exec ./_build/prod/rel/shop_local/bin/shop_local start
# Finally run the server
PORT=4001 MIX_ENV=prod mix phx.server