Created
April 20, 2019 08:09
-
-
Save allenwyma/f247ec4dadfa1af18ab0b59cfcaad5e8 to your computer and use it in GitHub Desktop.
Elixir eDeliver with Nginx Proxy Pass
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
APP="" # app name | |
BUILD_HOST="" # IP Address or hostname of build server | |
BUILD_USER="" # ssh user for build server | |
BUILD_AT="/tmp/edeliver/app/builds" | |
STAGING_HOSTS="" # IP Address or hostname of staging server | |
STAGING_USER="" # ssh user for build server | |
DELIVER_TO="" # where you want to deploy the app to | |
# For *Phoenix* projects, symlink prod.secret.exs to our tmp source | |
pre_erlang_get_and_update_deps() { | |
local _prod_secret_path="" # where your prod.secret.exs file is on the build server | |
if [ "$TARGET_MIX_ENV" = "prod" ]; then | |
__sync_remote " | |
ln -sfn '$_prod_secret_path' '$BUILD_AT/config/prod.secret.exs' | |
" | |
fi | |
} | |
pre_erlang_clean_compile() { | |
status "Installing NPM dependencies" | |
__sync_remote " | |
[ -f ~/.profile ] && source ~/.profile | |
set -e | |
cd '$BUILD_AT/assets' | |
npm install $SILENCE | |
" | |
status "Building static files" | |
__sync_remote " | |
[ -f ~/.profile ] && source ~/.profile | |
set -e | |
cd '$BUILD_AT' | |
mkdir -p priv/static | |
cd '$BUILD_AT/assets' | |
npm run deploy $SILENCE | |
" | |
status "Running phx.digest" | |
__sync_remote " | |
[ -f ~/.profile ] && source ~/.profile | |
set -e | |
cd '$BUILD_AT' | |
APP='$APP' MIX_ENV='$TARGET_MIX_ENV' $MIX_CMD phx.digest $SILENCE | |
" | |
} |
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
server { | |
listen 80 default_server; | |
# server_name example.com; | |
root /user/app/priv/static; # path of where app is deploy to + /priv/static | |
access_log /var/log/nginx/app.access.log; | |
error_log /var/log/nginx/app.error.log; | |
location / { | |
index index.html; | |
# first attempt to serve request as file, then fall back to app | |
try_files $uri @app; | |
# expires max; | |
# access_log off; | |
} | |
location @app { | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Refrerer $http_referer; | |
proxy_set_header User-Agent $http_user_agent; | |
proxy_pass http://127.0.0.1:4000; | |
} | |
} |
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
use Mix.Config | |
config :app, AppWeb.Endpoint, | |
http: [:inet6, port: 4000], | |
url: [host: "", port: 80], # change host to IP Address or Hostname of app server | |
cache_static_manifest: "priv/static/cache_manifest.json", | |
server: true | |
# Do not print debug messages in production | |
config :logger, level: :info | |
import_config "prod.secret.exs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment