All Projects → gjaldon → Heroku Buildpack Phoenix Static

gjaldon / Heroku Buildpack Phoenix Static

Licence: mit
A Heroku buildpack for building Phoenix's static assets

Programming Languages

shell
77523 projects
elixir
2628 projects

Projects that are alternatives of or similar to Heroku Buildpack Phoenix Static

Tune
A streamlined Spotify client and browser with a focus on performance and integrations.
Stars: ✭ 166 (-26.22%)
Mutual labels:  phoenix
Phoenix And Elm
Example application using Elixir, Phoenix and Elm
Stars: ✭ 188 (-16.44%)
Mutual labels:  phoenix
Codebattle
Codebattle game
Stars: ✭ 209 (-7.11%)
Mutual labels:  phoenix
Logster
Easily parsable single line, plain text and JSON logger for Plug and Phoenix applications
Stars: ✭ 171 (-24%)
Mutual labels:  phoenix
Phoenix client
Elixir Phoenix Client for Channels
Stars: ✭ 180 (-20%)
Mutual labels:  phoenix
Observer live
A port of observer_cli using LiveView
Stars: ✭ 202 (-10.22%)
Mutual labels:  phoenix
Passport
Provides authentication for phoenix application
Stars: ✭ 159 (-29.33%)
Mutual labels:  phoenix
Ex Shop
Digital goods shop & blog created using Elixir (Phoenix framework)
Stars: ✭ 214 (-4.89%)
Mutual labels:  phoenix
Elm Phoenix
An Elm client for Phoenix Channels
Stars: ✭ 183 (-18.67%)
Mutual labels:  phoenix
Formex
A better form library for Phoenix
Stars: ✭ 206 (-8.44%)
Mutual labels:  phoenix
Appsignal Elixir
🟪 AppSignal for Elixir package
Stars: ✭ 176 (-21.78%)
Mutual labels:  phoenix
Ueberauth example
Example Phoenix application using Überauth for authentication
Stars: ✭ 180 (-20%)
Mutual labels:  phoenix
Docker Web Framework Examples
Example apps that demonstate how to use Docker with your favorite web frameworks.
Stars: ✭ 204 (-9.33%)
Mutual labels:  phoenix
Phoenix Ecto Encryption Example
🔐 A detailed example for how to encrypt data in a Phoenix (Elixir) App before inserting into a database using Ecto Types
Stars: ✭ 166 (-26.22%)
Mutual labels:  phoenix
Absinthe plug
Plug support for Absinthe, the GraphQL toolkit for Elixir
Stars: ✭ 209 (-7.11%)
Mutual labels:  phoenix
Inquisitor
Composable query builder for Ecto
Stars: ✭ 162 (-28%)
Mutual labels:  phoenix
Changelog.com
Changelog is news and podcast for developers. This is our open source platform.
Stars: ✭ 2,354 (+946.22%)
Mutual labels:  phoenix
Heroku Buildpack Google Chrome
Run (headless) Google Chrome on Heroku
Stars: ✭ 215 (-4.44%)
Mutual labels:  heroku-buildpack
Subdir Heroku Buildpack
Allows to use subdirectory configured via environment variable as a project root
Stars: ✭ 211 (-6.22%)
Mutual labels:  heroku-buildpack
Realtime
Listen to your to PostgreSQL database in realtime via websockets. Built with Elixir.
Stars: ✭ 4,278 (+1801.33%)
Mutual labels:  phoenix

Phoenix Static Buildpack

Purpose

This buildpack is meant to be used with the Heroku Buildpack for Elixir. When deploying Phoenix apps to Heroku, static assets will need to be compiled. This buildpack sees to it that static assets are compiled and that a corresponding asset manifest is generated.

Features

  • Easily customizable to your build needs with its compile hook!
  • Works much like the Heroku Buildpack for Elixir!
  • Easy configuration with phoenix_static_buildpack.config file
  • Automatically sets DATABASE_URL
  • If your app doesn't have a Procfile, default web task mix phx.server will be run
  • Can configure versions for Node and NPM
  • Auto-installs Bower deps if bower.json is in your app's root path
  • Caches Node, NPM modules and Bower components

Usage

# Create a Heroku instance for your project
heroku apps:create my_heroku_app

# Set and add the buildpacks for your Heroku app
heroku buildpacks:set https://github.com/HashNuke/heroku-buildpack-elixir
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static

# Deploy
git push heroku master

Serve with Sass assets

If your project serves Sass assets, you need the sass binary for sass-brunch via ruby buildpack.

Create a Gemfile to include the sass gem:

source 'https://rubygems.org'
ruby '2.3.1'
gem 'sass'

Then run generate the Gemfile.lock:

bundle install

Finally, add the ruby buildpack.

# Add the ruby buildpack to your Heroku app
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-ruby

Configuration

Create a phoenix_static_buildpack.config file in your app's root dir if you want to override the defaults. The file's syntax is bash.

If you don't specify a config option, then the default option from the buildpack's phoenix_static_buildpack.config file will be used.

Here's a full config file with all available options:

# Clean out cache contents from previous deploys
clean_cache=false

# We can change the filename for the compile script with this option
compile="compile"

# We can set the version of Node to use for the app here
node_version=5.3.0

# We can set the version of NPM to use for the app here
npm_version=2.10.1

# We can set the version of Yarn to use for the app here
yarn_version=1.13.0

# We can set the path to phoenix app. E.g. apps/phoenix_app when in umbrella.
phoenix_relative_path=.

# Remove node and node_modules directory to keep slug size down if it is not needed.
remove_node=false

# We can change path that npm dependencies are in relation to phoenix app. E.g. assets for phoenix 1.3 support.
assets_path=.

# We can change phoenix mix namespace tasks. E.g. `phoenix` for phoenix < 1.3 support.
phoenix_ex=phx

Compile

By default, Phoenix uses brunch and recommends you to use mix phx.digest in production. For that, we have a default compile shell script which gets run after building dependencies and just before finalizing the build. The compile file looks like this.

To customize your app's compile hook, just add a compile file to your app's root directory. compile is just a shell script, so you can use any valid bash code. Keep in mind you'll have access to your node_modules and mix. This means that if you're using a Node build tool other than brunch, you can just do something like:

# app_root/compile
cd $phoenix_dir
npm --prefix ./assets run build
mix "${phoenix_ex}.digest" #use the ${phoenix_ex} variable instead of hardcoding phx or phoenix

The above compile overrides the default one. :)

FAQ

  1. When to use?
  • This buildpack is only necessary when you need to compile static assets during deploys. You will not need this buildpack if you are using Phoenix only as a REST API.
  1. Do I need heroku-buildpack-nodejs with this?
  • No, this buildpack installs Node for you. How it differs from the NodeJS buildpack is that it adds mix to the PATH so you can run mix commands like mix phx.digest.
  1. I am getting an error Command "deploy" not found. even though my previous deploys used to work. How to fix?
  • The default compile file, which are a set of commands ran during the buildpack's compile hook, was replaced to be compatible with Phoenix versions 1.4 and above. If using brunch and older versions of Phoenix, you will need to add a custom compile in your app's root directory that looks like:
brunch build --production

cd $phoenix_dir

mix "${phoenix_ex}.digest"

if mix help "${phoenix_ex}.digest.clean" 1>/dev/null 2>&1; then
  mix "${phoenix_ex}.digest.clean"
fi
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].