-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a351907
Showing
89 changed files
with
6,740 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file excludes paths from the Docker build context. | ||
# | ||
# By default, Docker's build context includes all files (and folders) in the | ||
# current directory. Even if a file isn't copied into the container it is still sent to | ||
# the Docker daemon. | ||
# | ||
# There are multiple reasons to exclude files from the build context: | ||
# | ||
# 1. Prevent nested folders from being copied into the container (ex: exclude | ||
# /assets/node_modules when copying /assets) | ||
# 2. Reduce the size of the build context and improve build time (ex. /build, /deps, /doc) | ||
# 3. Avoid sending files containing sensitive information | ||
# | ||
# More information on using .dockerignore is available here: | ||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
|
||
.dockerignore | ||
|
||
# Ignore git, but keep git HEAD and refs to access current commit hash if needed: | ||
# | ||
# $ cat .git/HEAD | awk '{print ".git/"$2}' | xargs cat | ||
# d0b8727759e1e0e7aa3d41707d12376e373d5ecc | ||
.git | ||
!.git/HEAD | ||
!.git/refs | ||
|
||
# Common development/test artifacts | ||
/cover/ | ||
/doc/ | ||
/test/ | ||
/tmp/ | ||
.elixir_ls | ||
|
||
# Mix artifacts | ||
/_build/ | ||
/deps/ | ||
*.ez | ||
|
||
# Generated on crash by the VM | ||
erl_crash.dump | ||
|
||
# Static artifacts - These should be fetched and built inside the Docker image | ||
/assets/node_modules/ | ||
/priv/static/assets/ | ||
/priv/static/cache_manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
import_deps: [:ecto, :ecto_sql, :phoenix], | ||
subdirectories: ["priv/*/migrations"], | ||
plugins: [Phoenix.LiveView.HTMLFormatter], | ||
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where 3rd-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
mentat-*.tar | ||
|
||
# Ignore assets that are produced by build tools. | ||
/priv/static/assets/ | ||
|
||
# Ignore digested assets cache. | ||
/priv/static/cache_manifest.json | ||
|
||
# In case you use Node.js/npm, you want to ignore these. | ||
npm-debug.log | ||
/assets/node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian | ||
# instead of Alpine to avoid DNS resolution issues in production. | ||
# | ||
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu | ||
# https://hub.docker.com/_/ubuntu?tab=tags | ||
# | ||
# This file is based on these images: | ||
# | ||
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image | ||
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20240722-slim - for the release image | ||
# - https://pkgs.org/ - resource for finding needed packages | ||
# - Ex: hexpm/elixir:1.17.2-erlang-27.0.1-debian-bullseye-20240722-slim | ||
# | ||
ARG ELIXIR_VERSION=1.17.2 | ||
ARG OTP_VERSION=27.0.1 | ||
ARG DEBIAN_VERSION=bullseye-20240722-slim | ||
|
||
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" | ||
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}" | ||
|
||
FROM ${BUILDER_IMAGE} as builder | ||
|
||
# install build dependencies | ||
RUN apt-get update -y && apt-get install -y build-essential git \ | ||
&& apt-get clean && rm -f /var/lib/apt/lists/*_* | ||
|
||
# prepare build dir | ||
WORKDIR /app | ||
|
||
# install hex + rebar | ||
RUN mix local.hex --force && \ | ||
mix local.rebar --force | ||
|
||
# set build ENV | ||
ENV MIX_ENV="prod" | ||
|
||
# install mix dependencies | ||
COPY mix.exs mix.lock ./ | ||
RUN mix deps.get --only $MIX_ENV | ||
RUN mkdir config | ||
|
||
# copy compile-time config files before we compile dependencies | ||
# to ensure any relevant config change will trigger the dependencies | ||
# to be re-compiled. | ||
COPY config/config.exs config/${MIX_ENV}.exs config/ | ||
RUN mix deps.compile | ||
|
||
COPY priv priv | ||
|
||
COPY lib lib | ||
|
||
COPY assets assets | ||
|
||
# compile assets | ||
RUN mix assets.deploy | ||
|
||
# Compile the release | ||
RUN mix compile | ||
|
||
# Changes to config/runtime.exs don't require recompiling the code | ||
COPY config/runtime.exs config/ | ||
|
||
COPY rel rel | ||
RUN mix release | ||
|
||
# start a new build stage so that the final image will only contain | ||
# the compiled release and other runtime necessities | ||
FROM ${RUNNER_IMAGE} | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \ | ||
&& apt-get clean && rm -f /var/lib/apt/lists/*_* | ||
|
||
# Set the locale | ||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen | ||
|
||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
WORKDIR "/app" | ||
RUN chown nobody /app | ||
|
||
# set runner ENV | ||
ENV MIX_ENV="prod" | ||
|
||
# Only copy the final release from the build stage | ||
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/mentat ./ | ||
|
||
USER nobody | ||
|
||
# If using an environment that doesn't automatically reap zombie processes, it is | ||
# advised to add an init process such as tini via `apt-get install` | ||
# above and adding an entrypoint. See https://github.com/krallin/tini for details | ||
# ENTRYPOINT ["/tini", "--"] | ||
|
||
CMD ["sh", "-c", "/app/bin/migrate && exec /app/bin/server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Mentat | ||
|
||
To start your Phoenix server: | ||
|
||
* Run `mix setup` to install and setup dependencies | ||
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import "tailwindcss/base"; | ||
@import "tailwindcss/components"; | ||
@import "tailwindcss/utilities"; | ||
|
||
/* This file is for your main application CSS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// If you want to use Phoenix channels, run `mix help phx.gen.channel` | ||
// to get started and then uncomment the line below. | ||
// import "./user_socket.js" | ||
|
||
// You can include dependencies in two ways. | ||
// | ||
// The simplest option is to put them in assets/vendor and | ||
// import them using relative paths: | ||
// | ||
// import "../vendor/some-package.js" | ||
// | ||
// Alternatively, you can `npm install some-package --prefix assets` and import | ||
// them using a path starting with the package name: | ||
// | ||
// import "some-package" | ||
// | ||
|
||
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons. | ||
import "phoenix_html" | ||
// Establish Phoenix Socket and LiveView configuration. | ||
import {Socket} from "phoenix" | ||
import {LiveSocket} from "phoenix_live_view" | ||
import topbar from "../vendor/topbar" | ||
|
||
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") | ||
let liveSocket = new LiveSocket("/live", Socket, { | ||
longPollFallbackMs: 2500, | ||
params: {_csrf_token: csrfToken} | ||
}) | ||
|
||
// Show progress bar on live navigation and form submits | ||
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"}) | ||
window.addEventListener("phx:page-loading-start", _info => topbar.show(300)) | ||
window.addEventListener("phx:page-loading-stop", _info => topbar.hide()) | ||
|
||
// connect if there are any LiveViews on the page | ||
liveSocket.connect() | ||
|
||
// expose liveSocket on window for web console debug logs and latency simulation: | ||
// >> liveSocket.enableDebug() | ||
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session | ||
// >> liveSocket.disableLatencySim() | ||
window.liveSocket = liveSocket | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// See the Tailwind configuration guide for advanced usage | ||
// https://tailwindcss.com/docs/configuration | ||
|
||
const plugin = require("tailwindcss/plugin") | ||
const fs = require("fs") | ||
const path = require("path") | ||
|
||
module.exports = { | ||
content: [ | ||
"./js/**/*.js", | ||
"../lib/mentat_web.ex", | ||
"../lib/mentat_web/**/*.*ex" | ||
], | ||
theme: { | ||
extend: { | ||
colors: { | ||
brand: "#FD4F00", | ||
} | ||
}, | ||
}, | ||
plugins: [ | ||
require("@tailwindcss/forms"), | ||
// Allows prefixing tailwind classes with LiveView classes to add rules | ||
// only when LiveView classes are applied, for example: | ||
// | ||
// <div class="phx-click-loading:animate-ping"> | ||
// | ||
plugin(({addVariant}) => addVariant("phx-click-loading", [".phx-click-loading&", ".phx-click-loading &"])), | ||
plugin(({addVariant}) => addVariant("phx-submit-loading", [".phx-submit-loading&", ".phx-submit-loading &"])), | ||
plugin(({addVariant}) => addVariant("phx-change-loading", [".phx-change-loading&", ".phx-change-loading &"])), | ||
|
||
// Embeds Heroicons (https://heroicons.com) into your app.css bundle | ||
// See your `CoreComponents.icon/1` for more information. | ||
// | ||
plugin(function({matchComponents, theme}) { | ||
let iconsDir = path.join(__dirname, "../deps/heroicons/optimized") | ||
let values = {} | ||
let icons = [ | ||
["", "/24/outline"], | ||
["-solid", "/24/solid"], | ||
["-mini", "/20/solid"], | ||
["-micro", "/16/solid"] | ||
] | ||
icons.forEach(([suffix, dir]) => { | ||
fs.readdirSync(path.join(iconsDir, dir)).forEach(file => { | ||
let name = path.basename(file, ".svg") + suffix | ||
values[name] = {name, fullPath: path.join(iconsDir, dir, file)} | ||
}) | ||
}) | ||
matchComponents({ | ||
"hero": ({name, fullPath}) => { | ||
let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "") | ||
let size = theme("spacing.6") | ||
if (name.endsWith("-mini")) { | ||
size = theme("spacing.5") | ||
} else if (name.endsWith("-micro")) { | ||
size = theme("spacing.4") | ||
} | ||
return { | ||
[`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`, | ||
"-webkit-mask": `var(--hero-${name})`, | ||
"mask": `var(--hero-${name})`, | ||
"mask-repeat": "no-repeat", | ||
"background-color": "currentColor", | ||
"vertical-align": "middle", | ||
"display": "inline-block", | ||
"width": size, | ||
"height": size | ||
} | ||
} | ||
}, {values}) | ||
}) | ||
] | ||
} |
Oops, something went wrong.