$ mix phoenix.new --no-brunch --no-html --binary-id api
Last active
July 20, 2016 02:44
-
-
Save gullitmiranda/e0f7755f77c6029482b9 to your computer and use it in GitHub Desktop.
Elixir + Phoenix (API) Azkfile - initial instructions in README.md
This file contains hidden or 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
| /** | |
| * Documentation: http://docs.azk.io/Azkfile.js | |
| */ | |
| var name = "api"; | |
| var ENV = env.DEPLOY_ENV || "stage"; | |
| var domain = "domain.com"; | |
| // var domain = (ENV == "prod") ? "domain.com" : "cloudapp.net" ; | |
| var subdomain = (ENV == "prod") ? name : (name + "-" + ENV); | |
| var host = subdomain + "." + domain; | |
| var domains = [ | |
| host, | |
| "#{env.HOST_IP}", | |
| "#{system.name}.#{azk.default_domain}", | |
| ]; | |
| // Adds the systems that shape your system | |
| systems({ | |
| api: { | |
| // Dependent systems | |
| depends: ["postgres", "s3"], | |
| // More images: http://images.azk.io | |
| image: {"docker": "azukiapp/elixir-pg-imagick:1.3"}, | |
| // Steps to execute before running instances | |
| provision: [ | |
| "provision.sh", | |
| ], | |
| workdir: "/azk/#{manifest.dir}", | |
| command: ["mix", "phoenix.server", "--no-deps-check"], | |
| wait: 120, | |
| mounts: { | |
| '/azk/#{manifest.dir}' : sync("."), | |
| '/azk/#{manifest.dir}/deps' : persistent("./deps"), | |
| '/azk/#{manifest.dir}/_build': persistent("./_build"), | |
| '/root/.hex' : persistent("./tmp/.hex"), | |
| }, | |
| scalable: {"default": 1}, | |
| http: { | |
| domains: [ "#{system.name}.#{azk.default_domain}" ] | |
| }, | |
| ports: { | |
| // exports global variables | |
| http: "4000", | |
| }, | |
| envs: { | |
| // Make sure that the PORT value is the same as the one | |
| // in ports/http below, and that it's also the same | |
| // if you're setting it in a .env file | |
| MIX_ENV: "dev", | |
| HOST: "#{system.name}.#{azk.default_domain}", | |
| } | |
| }, | |
| postgres: { | |
| // More info about postgres image: http://images.azk.io/#/postgres?from=images-azkfile-postgres | |
| image: {"docker": "azukiapp/postgres:9.5"}, | |
| shell: "/bin/bash", | |
| wait: 30, | |
| mounts: { | |
| '/var/lib/postgresql/data': persistent("#{system.name}-data"), | |
| // to clean postgres data, run: | |
| // $ azk shell postgres -c "rm -rf /var/lib/postgresql/data/*" | |
| }, | |
| ports: { | |
| // exports global variables: "#{net.port.data}" | |
| data: "5432/tcp", | |
| }, | |
| envs: { | |
| // set instances variables | |
| POSTGRES_USER: "azk", | |
| POSTGRES_PASS: "azk", | |
| POSTGRES_DB : "#{manifest.dir}", | |
| }, | |
| export_envs: { | |
| // check this gist to configure your database | |
| // Exlir eg in: https://github.com/azukiapp/hello_phoenix/blob/master/config/database.uri.exs | |
| DATABASE_URL: "ecto+postgres://#{envs.POSTGRES_USER}:#{envs.POSTGRES_PASS}@#{net.host}:#{net.port.data}/#{envs.POSTGRES_DB}", | |
| }, | |
| }, | |
| "s3": { | |
| image: {docker: "lphoward/fake-s3"}, | |
| command: ["fakes3", "-r", "/fakes3", "-p", "$HTTP_PORT"], | |
| shell: "/bin/bash", | |
| workdir: "/fakes3", | |
| mounts: { | |
| '/fakes3': persistent("fake-s3"), | |
| // to clean postgres data, run: | |
| // $ azk shell s3 -c "rm -rf /fakes3/*" | |
| }, | |
| http: { | |
| // bucket + domain | |
| domains: [ "liveguide.#{system.name}.#{azk.default_domain}" ] | |
| }, | |
| ports: { | |
| // exports global variables: "#{net.port.data}" | |
| http: "4569/tcp", | |
| }, | |
| export_envs: { | |
| S3_HOST : "#{system.name}.#{azk.default_domain}", | |
| S3_BUCKET: "liveguide", | |
| // not use http:// (more info in https://github.com/benoitc/hackney/pull/210) | |
| S3_SCHEME: "", | |
| // S3_REGION: "", | |
| }, | |
| docker_extra: { | |
| Entrypoint: [], | |
| } | |
| }, | |
| /* TEST */ | |
| "postgres-test": { | |
| extends: "postgres", | |
| scalable: { default: 0, limit: 1 }, | |
| envs: { | |
| // set instances variables | |
| POSTGRES_USER: "azk", | |
| POSTGRES_PASS: "azk", | |
| POSTGRES_DB : "#{manifest.dir}_test", | |
| }, | |
| }, | |
| test: { | |
| extends: "api", | |
| depends: ["postgres-test", "s3"], | |
| command: "exit 0", | |
| scalable: { default: 0, limit: 1 }, | |
| http: false, | |
| wait: false, | |
| envs: { | |
| MIX_ENV: "test", | |
| HOST : "#{system.name}.#{azk.default_domain}", | |
| }, | |
| }, | |
| /* Deploy */ | |
| // to deploy in STAGE run: `make deploy[-stage]` or `azk deploy` | |
| // to deploy in PROD run: `make deploy-prod` or `DEPLOY_ENV=prod azk deploy` | |
| deploy: { | |
| image: {"docker": "azukiapp/deploy"}, | |
| mounts: { | |
| "/azk/deploy/src" : path("."), | |
| "/azk/deploy/.ssh" : path("#{env.HOME}/.ssh"), | |
| "/azk/deploy/.config": persistent("deploy-config-" + ENV), | |
| }, | |
| scalable: {"default": 0, "limit": 0}, | |
| envs: { | |
| REMOTE_PROJECT_PATH_ID: name, | |
| ENV_FILE : ".env." + ENV, | |
| AZK_RESTART_COMMAND : "azk restart postgres && azk restart prod -Bvvvv", | |
| HOST_DOMAIN : host, | |
| REMOTE_HOST : host, | |
| // REMOTE_PORT : 5022, | |
| // REMOTE_ROOT_USER : 'git', | |
| AZK_ENV : ENV, | |
| }, | |
| }, | |
| /* PRODUCTION */ | |
| prod: { | |
| extends: "api", | |
| depends: ["postgres"], | |
| provision: [ | |
| "provision.sh", | |
| ], | |
| wait: 200, | |
| http: { | |
| domains: domains, | |
| }, | |
| ports: { | |
| // exports global variables | |
| http: "4000:4000/tcp", | |
| }, | |
| scalable: {"default": 0, "limit": 0}, | |
| envs: { | |
| MIX_ENV : "prod", | |
| AZK_ENV : ENV, | |
| HOST : host, | |
| HOST_DOMAIN: host, | |
| TERM : "linux", | |
| }, | |
| }, | |
| }); |
This file contains hidden or 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
| #! /bin/sh | |
| # - Show and exit on errors | |
| set -ex | |
| mix deps.get | |
| mix deps.compile | |
| mix deps.install | |
| mix ecto.migrate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment