feat: make production ready
This commit is contained in:
parent
0c721e9296
commit
3b196006c0
9 changed files with 87 additions and 70 deletions
1
Makefile
1
Makefile
|
|
@ -27,6 +27,7 @@ authelia-start: ${AUTHELIA_PID}
|
||||||
${AUTHELIA_PID}: ${AUTHELIA_CONFIG}
|
${AUTHELIA_PID}: ${AUTHELIA_CONFIG}
|
||||||
mkdir -p ${AUTHELIA_HOME}/tmp/
|
mkdir -p ${AUTHELIA_HOME}/tmp/
|
||||||
cd ${AUTHELIA_HOME}
|
cd ${AUTHELIA_HOME}
|
||||||
|
mkdir -p $(dir ${AUTHELIA_PID})
|
||||||
authelia --config ${AUTHELIA_CONFIG} &> ${AUTHELIA_LOG} &
|
authelia --config ${AUTHELIA_CONFIG} &> ${AUTHELIA_LOG} &
|
||||||
echo $$! > ${AUTHELIA_PID}
|
echo $$! > ${AUTHELIA_PID}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ config :putzplan,
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :putzplan, PutzplanWeb.Endpoint,
|
config :putzplan, PutzplanWeb.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "127.0.0.1"],
|
||||||
adapter: Bandit.PhoenixAdapter,
|
adapter: Bandit.PhoenixAdapter,
|
||||||
render_errors: [
|
render_errors: [
|
||||||
formats: [html: PutzplanWeb.ErrorHTML, json: PutzplanWeb.ErrorJSON],
|
formats: [html: PutzplanWeb.ErrorHTML, json: PutzplanWeb.ErrorJSON],
|
||||||
|
|
@ -99,6 +99,8 @@ config :logger, :console,
|
||||||
# Use Jason for JSON parsing in Phoenix
|
# Use Jason for JSON parsing in Phoenix
|
||||||
config :phoenix, :json_library, Jason
|
config :phoenix, :json_library, Jason
|
||||||
|
|
||||||
|
config :exqlite, force_build: true
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{config_env()}.exs"
|
import_config "#{config_env()}.exs"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ config :live_debugger, browser_features?: true
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :putzplan, Putzplan.Repo,
|
config :putzplan, Putzplan.Repo,
|
||||||
username: "postgres",
|
|
||||||
password: "postgres",
|
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
database: "tmp/putzplan_dev",
|
database: "tmp/putzplan_dev",
|
||||||
stacktrace: true,
|
stacktrace: true,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import Config
|
||||||
# manifest is generated by the `mix assets.deploy` task,
|
# manifest is generated by the `mix assets.deploy` task,
|
||||||
# which you should run after static files are built and
|
# which you should run after static files are built and
|
||||||
# before starting your production server.
|
# before starting your production server.
|
||||||
config :putzplan, PutzplanWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
|
config :putzplan, PutzplanWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json", server: true
|
||||||
|
|
||||||
# Configures Swoosh API Client
|
# Configures Swoosh API Client
|
||||||
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Putzplan.Finch
|
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Putzplan.Finch
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,15 @@ if System.get_env("PHX_SERVER") do
|
||||||
end
|
end
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
database_url =
|
database =
|
||||||
System.get_env("DATABASE_URL") ||
|
System.get_env("DATABASE") ||
|
||||||
raise """
|
raise """
|
||||||
environment variable DATABASE_URL is missing.
|
environment variable DATABASE is missing.
|
||||||
For example: ecto://USER:PASS@HOST/DATABASE
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
|
||||||
|
|
||||||
config :putzplan, Putzplan.Repo,
|
config :putzplan, Putzplan.Repo,
|
||||||
# ssl: true,
|
database: database,
|
||||||
url: database_url,
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "1")
|
||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
|
||||||
socket_options: maybe_ipv6
|
|
||||||
|
|
||||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
# The secret key base is used to sign/encrypt cookies and other secrets.
|
||||||
# A default value is used in config/dev.exs and config/test.exs but you
|
# A default value is used in config/dev.exs and config/test.exs but you
|
||||||
|
|
|
||||||
104
flake.nix
104
flake.nix
|
|
@ -6,39 +6,87 @@
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = {
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
self,
|
||||||
let
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system: let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in
|
erl = pkgs.beam.interpreters.erlang_27;
|
||||||
{
|
erlangPackages = pkgs.beam.packagesWith erl;
|
||||||
|
elixir = erlangPackages.elixir;
|
||||||
|
in {
|
||||||
|
packages = let
|
||||||
|
version = "0.1.0";
|
||||||
|
src = ./.;
|
||||||
|
mixFodDeps = erlangPackages.fetchMixDeps {
|
||||||
|
inherit version src;
|
||||||
|
pname = "putzplan";
|
||||||
|
sha256 = "sha256-H8FFuNayJcFvESWlGYr6H6L5zSzAjqBixBmob5Gnoc4=";
|
||||||
|
};
|
||||||
|
translatedPlatform =
|
||||||
|
pkgs.lib.getAttr
|
||||||
|
system
|
||||||
|
{
|
||||||
|
aarch64-darwin = "macos-arm64";
|
||||||
|
aarch64-linux = "linux-arm64";
|
||||||
|
armv7l-linux = "linux-armv7";
|
||||||
|
x86_64-darwin = "macos-x64";
|
||||||
|
x86_64-linux = "linux-x64";
|
||||||
|
};
|
||||||
|
in rec {
|
||||||
|
default = erlangPackages.mixRelease {
|
||||||
|
inherit version src mixFodDeps;
|
||||||
|
pname = "putzplan";
|
||||||
|
|
||||||
|
preInstall = ''
|
||||||
|
ln -s ${pkgs.tailwindcss}/bin/tailwindcss _build/tailwind-${translatedPlatform}
|
||||||
|
ln -s ${pkgs.esbuild}/bin/esbuild _build/esbuild-${translatedPlatform}
|
||||||
|
|
||||||
|
${elixir}/bin/mix assets.deploy
|
||||||
|
${elixir}/bin/mix phx.gen.release
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
dockerImage = pkgs.dockerTools.buildImage {
|
||||||
|
name = "putzplan";
|
||||||
|
config = {
|
||||||
|
Entrypoint = "${default}/bin/putzplan";
|
||||||
|
Cmd = "start";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs;
|
||||||
erlang_25
|
[
|
||||||
beam.packages.erlang_25.elixir_1_18
|
erl
|
||||||
lexical
|
elixir
|
||||||
beam.packages.erlang_25.elixir-ls
|
lexical
|
||||||
next-ls
|
erlangPackages.elixir-ls
|
||||||
|
next-ls
|
||||||
|
|
||||||
sqlite
|
gnumake
|
||||||
gnumake
|
authelia
|
||||||
authelia
|
lazysql
|
||||||
]
|
|
||||||
++ lib.optionals stdenv.isLinux [
|
|
||||||
# For ExUnit Notifier on Linux.
|
|
||||||
libnotify
|
|
||||||
|
|
||||||
# For file_system on Linux.
|
nix-output-monitor
|
||||||
inotify-tools
|
]
|
||||||
]
|
++ lib.optionals stdenv.isLinux [
|
||||||
++ lib.optionals stdenv.isDarwin ([
|
# For ExUnit Notifier on Linux.
|
||||||
# For ExUnit Notifier on macOS.
|
libnotify
|
||||||
terminal-notifier
|
|
||||||
|
|
||||||
# For file_system on macOS.
|
# For file_system on Linux.
|
||||||
darwin.apple_sdk.frameworks.CoreFoundation
|
inotify-tools
|
||||||
darwin.apple_sdk.frameworks.CoreServices
|
]
|
||||||
]);
|
++ lib.optionals stdenv.isDarwin [
|
||||||
|
# For ExUnit Notifier on macOS.
|
||||||
|
terminal-notifier
|
||||||
|
|
||||||
|
# For file_system on macOS.
|
||||||
|
darwin.apple_sdk.frameworks.CoreFoundation
|
||||||
|
darwin.apple_sdk.frameworks.CoreServices
|
||||||
|
];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export OIDC_CLIENT_ID="putzplan"
|
export OIDC_CLIENT_ID="putzplan"
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,3 @@
|
||||||
<header class="px-4 sm:px-6 lg:px-8">
|
|
||||||
<div class="flex items-center justify-between border-b border-zinc-100 py-3 text-sm">
|
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<a href="/">
|
|
||||||
<img src={~p"/images/logo.svg"} width="36" />
|
|
||||||
</a>
|
|
||||||
<p class="bg-brand/5 text-brand rounded-full px-2 font-medium leading-6">
|
|
||||||
v{Application.spec(:phoenix, :vsn)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900">
|
|
||||||
<a href="https://twitter.com/elixirphoenix" class="hover:text-zinc-700">
|
|
||||||
@elixirphoenix
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/phoenixframework/phoenix" class="hover:text-zinc-700">
|
|
||||||
GitHub
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href="https://hexdocs.pm/phoenix/overview.html"
|
|
||||||
class="rounded-lg bg-zinc-100 px-2 py-1 hover:bg-zinc-200/80"
|
|
||||||
>
|
|
||||||
Get Started <span aria-hidden="true">→</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<main class="px-4 py-20 sm:px-6 lg:px-8">
|
<main class="px-4 py-20 sm:px-6 lg:px-8">
|
||||||
<div class="mx-auto max-w-2xl">
|
<div class="mx-auto max-w-2xl">
|
||||||
<.flash_group flash={@flash} />
|
<.flash_group flash={@flash} />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="csrf-token" content={get_csrf_token()} />
|
<meta name="csrf-token" content={get_csrf_token()} />
|
||||||
<.live_title default="Putzplan" suffix=" · Phoenix Framework">
|
<.live_title default="Putzplan">
|
||||||
{assigns[:page_title]}
|
{assigns[:page_title]}
|
||||||
</.live_title>
|
</.live_title>
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||||
|
|
|
||||||
1
mix.exs
1
mix.exs
|
|
@ -45,7 +45,6 @@ defmodule Putzplan.MixProject do
|
||||||
{:phoenix, "~> 1.7.21"},
|
{:phoenix, "~> 1.7.21"},
|
||||||
{:phoenix_ecto, "~> 4.5"},
|
{:phoenix_ecto, "~> 4.5"},
|
||||||
{:ecto_sql, "~> 3.10"},
|
{:ecto_sql, "~> 3.10"},
|
||||||
{:postgrex, ">= 0.0.0"},
|
|
||||||
{:phoenix_html, "~> 4.1"},
|
{:phoenix_html, "~> 4.1"},
|
||||||
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
||||||
{:phoenix_live_view, "~> 1.0"},
|
{:phoenix_live_view, "~> 1.0"},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue