Skip to content

Instantly share code, notes, and snippets.

View paveltyk's full-sized avatar

Pavel Tsiukhtsiayeu paveltyk

  • BILL
  • North Carolina, US
  • 01:33 (UTC -04:00)
View GitHub Profile
defmodule GoogleStorage.Application do
# ...
@impl true
def start(_type, _args) do
producer_module = Application.get_env(:google_storage, :producer_module)
children = [
{GoogleStorage.Pipeline, [producer_module: producer_module]}
defmodule GoogleStorage.Pipeline do
use Broadway
require Logger
alias Broadway.Message
def start_link(opts) do
producer_module = Keyword.fetch!(opts, :producer_module)
Broadway.start_link(__MODULE__,
# config/config.exs
import Config
config :goth, json: File.read!("priv/creds.json")
subscription = "projects/gcs-pubsub-1/subscriptions/api-subscription"
config :google_storage,
producer_module: {BroadwayCloudPubSub.Producer, subscription: subscription}
build:
docker:
web: Dockerfile
release:
image: web
command:
- POOL_SIZE=2 mix ecto.migrate
run:
web: mix phx.server
FROM node:10-alpine AS assets
WORKDIR /app/assets
COPY ./assets /app/assets
RUN yarn install && yarn build
FROM elixir:1.9.1-alpine
ARG MIX_ENV=prod
ARG DATABASE_URL=postgres://postgres:postgres@localhost/healthyskin_dev
ARG SECRET_KEY_BASE=secret
ENV MIX_HOME=/root/.mix
/.git
/_build
/deps
/assets/build
/assets/node_modules
# config/prod.exs - url builder options and `force_ssl` behind Heroku proxy
config :healthyskin, HealthyskinWeb.Endpoint,
url: [scheme: "https", host: "example.com", port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]]
# config/prod.secret.exs - use secure database connection
config :healthyskin, Healthyskin.Repo,
ssl: true,
defmodule HealthyskinWeb.PageView do
use HealthyskinWeb, :view
def render("index.html", _assigns) do
{:safe, File.read!("assets/build/index.html")}
end
end
defmodule HealthyskinWeb.PageController do
use HealthyskinWeb, :controller
plug :put_layout, false
def index(conn, _params) do
render(conn, "index.html")
end
end
# config/prod.exs - Remove cache_manifest
config :healthyskin, HealthyskinWeb.Endpoint, url: [host: "example.com", port: 80]
# lib/healthyskin_web/endpoint.ex - Instruct Plug.Static how to serve assets
plug Plug.Static,
at: "/",
from: "assets/build",
gzip: false,