GithubHelp home page GithubHelp logo

glepag1 / ansible-phoenix-build Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danschultzer/ansible-phoenix-build

0.0 2.0 0.0 98 KB

Sample app with full build and deploy setup of a Phoenix app using ansible

Home Page: https://dreamconception.com/tech/phoenix-automated-build-and-deploy-made-simple/

License: Other

DIGITAL Command Language 3.29% JavaScript 11.27% CSS 0.13% Shell 3.27% Elixir 76.57% HTML 5.47%

ansible-phoenix-build's Introduction

CircleCI Blog post

Ansible Phoenix Build

This sample repo is configured for production-ready build and deploy cycle. It contains an ansible setup that will maintain docker image, build phoenix app in docker image, and do automated versioned releases on your production server.

Commands

A set of binaries have been added to the bin/ directory.

Command What it does
bin/update-docker-image Builds and pushes the docker container used for building the Phoenix app.
bin/build Builds a release of the app.
bin/prepare-deploy-docker Prepare the docker container for deploy. This is only necessary for contained test of this repo.
bin/deploy Deploys a release of the app (to the docker image).

Vault pass

.ansible/.vault_pass.txt needs the following content for you to be able to run builds (this is obviously just for demo data):

ciloPBJybrzq51S7Sl3c0t6MjAAQhKn/FXJBRP3JM1YL9VSlTvcwP4GJa82ip83Q
s2uJGdPt9Edt4kqQa9PCEDz8ab2uJ3CMfuLw6BWiQmbiaDRNKZFs7P6i4/5txpcz
ppGE/IZaX4sdwM+DFyXnHfzLDRxmEmf7Jmlhcb1icqc3jbsvHQwKe0L+Sk2qyTs4
MZHca7cTI+247BrWuGqKMsxnpSHB8zuHCGqCAkwM1rSa9VQDbvSS9hH+TEg2ciXR
DWSrmiR3A3wdMsmdg/JxyOi2I4JAVp7mWkgH4clxVYlVru+nmVW9/14fv7kJnhxj
1cHUCAcGkDvbmP7ECqau9vlbhDBLCczbUDR4yY4Cw9zhJK5oJAZHIA==

Run build locally

You can run the build locally by doing the following:

docker attach ansible_phoenix_build_build_server
cd build/_build/prod/rel/ansible_phoenix_build
bin/ansible_phoenix_build foreground

Note that you'll need a database server to connect to. The fastest way if you're using postgres is to just run sh bin/prepare-deploy-docker to prepare the docker container with a postgres server and database.

Deploy to remote server

I recommend you to follow the blog post guide but you will be able to use this repo to deploy to a remote server.

  1. Search and replace example.com with your actual host name (both file name, and in files)
  2. Set up a deploy user on your remote host
  3. Create the deploy directory with mkdir -p /u/apps/ansible_phoenix_build/releases
  4. Make the directory writeable for the deploy user with: chown -R deploy /u/apps/ansible_phoenix_build
  5. Permit deploy user to run sudo /bin/systemctl restart ansible_phoenix_build.
  6. Add the following systemd configuration to /etc/systemd/system/ansible_phoenix_build.service:
    [Unit]
    Description=Server for ansible_phoenix_build
    Wants=postgres.service
    After=postgres.service
    After=syslog.target
    After=network.target
    
    [Service]
    Type=simple
    User=deploy
    Group=deploy
    WorkingDirectory=/u/apps/ansible_phoenix_build/current
    ExecStart=/u/apps/ansible_phoenix_build/current/bin/ansible_phoenix_build foreground
    KillMode=process
    Restart=on-failure
    SuccessExitStatus=143
    TimeoutSec=10
    RestartSec=5
    SyslogIdentifier=ansible_phoenix_build
    
    [Install]
    WantedBy=multi-user.target

You'll be able to deploy to your remote server now!

To use the bin/deploy command, remove the --user and --connection arguments.

Notes

  • Local deploys goes to the docker container
  • CI deploys goes to localhost

LICENSE

(The MIT License)

Copyright (c) 2017 Dan Schultzer & the Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.