Skip to content

Instantly share code, notes, and snippets.

View MicrexIT's full-sized avatar

Michele Rexha MicrexIT

View GitHub Profile
@MicrexIT
MicrexIT / app.js
Last active February 4, 2022 15:51
Phoenix <3 Algorand
import "../css/app.css";
import "phoenix_html";
import { Socket } from "phoenix";
import { LiveSocket } from "phoenix_live_view";
import topbar from "../vendor/topbar";
let Hooks = {};
Hooks.Connect = {
mounted() {
@MicrexIT
MicrexIT / Phoenix.release.ex
Created July 14, 2021 12:26
Elixir Phoenix release Deployment
defmodule MyApp.Release do
@app :my_app
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
@MicrexIT
MicrexIT / Phoenix.env
Last active July 14, 2021 11:55
Elixir Phoenix env Deployment
DATABASE_URL=ecto://user:pw@db_address/db_name
SECRET_KEY_BASE=your_secret_key_base
MIX_ENV=prod
APP_NAME=app_name
CONTAINER_NAME=app_container
IMAGE_NAME=app_image
APP_PORT=4000
NETWORK=your_network
@MicrexIT
MicrexIT / Phoenix.runtime.exs
Last active July 14, 2021 11:58
Elixir Phoenix runtime Deployment
```elixir
# config/prod.exs
import Config
config :your_app_otp_name, YourAppWeb.Endpoint,
# url: [host: "example.com", port: 80],
url: [host: "localhost", port: 4000],
cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production
config :logger, level: :info
@MicrexIT
MicrexIT / Phoenix.prod.exs
Last active July 14, 2021 11:54
Elixir Phoenix prod.exs Deployment
```elixir
# config/prod.exs
import Config
config :theme_ci_admin, YourAppWeb.Endpoint,
# url: [host: "example.com", port: 80],
url: [host: "localhost", port: 4000],
cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production
config :logger, level: :info
@MicrexIT
MicrexIT / Phoenix.config.exs
Last active July 14, 2021 11:53
Elixir Phoenix configs Deployment
# config/config.exs
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
# General application configuration
import Config
@MicrexIT
MicrexIT / Phoenix.Makefile
Created July 14, 2021 11:43
Elixir Phoenix Makefile Deployment
ifneq (,$(wildcard ./.env))
include .env
export
endif
build:
ifdef VERSION
docker build --rm \
--build-arg DATABASE_URL=$(DATABASE_URL) \
--build-arg SECRET_KEY_BASE=$(SECRET_KEY_BASE) \
@MicrexIT
MicrexIT / Phoenix.Dockerfile
Last active July 14, 2021 11:46
Elixir Phoenix Docker Deployment
FROM hexpm/elixir:1.11.2-erlang-23.1.2-alpine-3.12.1 as build
# install build dependencies
RUN apk add --no-cache build-base npm git python3 curl
# prepare build dir
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
var serverResponseCode: Int? = 404
// serverResponseCode contains an actual Int value of 404
serverResponseCode = nil
// serverResponseCode now contains no value
let http404Error = (404, "Not Found")