Skip to content

Instantly share code, notes, and snippets.

@lcuevastodoit
Last active July 12, 2020 01:04
Show Gist options
  • Save lcuevastodoit/a68af81ba175e421626479097fac3133 to your computer and use it in GitHub Desktop.
Save lcuevastodoit/a68af81ba175e421626479097fac3133 to your computer and use it in GitHub Desktop.
sudo apt install git
ssh-keygen
cat /home/user/.ssh/id_rsa.pub
copy the content
go to the github.com/user/myapp-repository/settings
ADD DEPLOY KEY
git clone git@github.com:user/myapp-repository.git
cd myapp
git pull
Already up to date.
mix deps.get (to grab the dependencies)
Shall I install Hex (package manager)?; Yes
cd assets
npm install
more package.json
CHECK webpack and webpack-cli are required
sudo npm install -g webpack
sudo npm install -g webpack-cli
cd..
more config/prod.exs
CHECK import_config "prod.secret.exs"
----------------------------------------
nano config/prod.secret.exs
use Mix.config
# Database settings:
config :myappp, Myapp.Repo,
host: "127.0.01",
port: 3306,
database: "phoenix_database",
username: "root",
passsword: "some_password",
pool_size: 10
# Web Endpoint settings:
config :myapp, MyappWeb.Endpoint # add Web word to Myapp
server: true,
http: [port: 4000, transport_options: [socket_opts: [:inet6]]],
url: [host: "mydomain.com", port: 80],
check_origin: [
"https://mydomain.com"'
"https://www.mydomain.com"'
"https://mydomain.com:4000"'
"https://www.mydomain.com:4000"'
],
secret_key_base: "DHW*(DHQ(WY#H#&D(UW#EH&DH#UDH(#DN#WI" # to generate key run "mix phx.gen.secret"
-------------------------------------------------
npm run deploy --prefix ./assets
mix phx.digest
MIX_ENV=prod mix compile # compilar la app en produccion
MIX_ENV=prod mix ecto.create # crear la db de produccion
MIX_ENV=prod mix ecto.migrate # migrar tablas
MIX_ENV=prod mix release
_build/prod/rel/myapp/bin/myapp start
open your app in http://mydomain.com:4000
stop now with CTRL-C twice
----------------------------------------------------
nano /etc/nginx/sites-available/mydomain.com
upstream phoenix (
server 127.0.0.1:4000;
)
MODIFY location to -> location / {
allow all;
# Proxy Headers
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
# Web Sockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://phoenix;
}
-------------------------------------------------
sudo nginx -t
sudo systemctl restart nginx
you must see 502 BAD GATEWAY now in https://mydomain.com
_buil/prod/rel/myapp/bin/myapp start # START WEB APP WITHOUT CONSOLE
_buil/prod/rel/myapp/bin/myapp daemon # AS DAEMON WITHOUT CONSOLE
_buil/prod/rel/myapp/bin/myapp start_iex # START WEB APP WITH CONSOLE
_buil/prod/rel/myapp/bin/myapp daemon_iex # AS DAEMON WITH CONSOLE
now in https://mydomain.com you can see the web app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment