diff --git a/.gitignore b/.gitignore index c460978c9..669afaf3f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ /build/package/work /build/package/verify/.rnd /deploy/.env +/deploy/log +/deploy/tmp /log/* /test/reports /test/tmp diff --git a/CMakeLists.txt b/CMakeLists.txt index 433d69c65..e6802b33e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(api-umbrella) option(ENABLE_HADOOP_ANALYTICS "Build dependencies for Hadoop analytics" off) option(ENABLE_TEST_DEPENDENCIES "Build dependencies for running tests" off) +option(ENABLE_DEPLOY_ONLY "Only build dependencies for a deployment overlaying an existing package install" off) # Installation prefix if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -32,7 +33,12 @@ set(HADOOP_ANALYTICS_STAGE_EMBEDDED_DIR ${HADOOP_ANALYTICS_STAGE_DIR}${INSTALL_P # Where to install app-level vendor dependencies. set(VENDOR_DIR ${WORK_DIR}/vendor) set(VENDOR_LUA_DIR ${VENDOR_DIR}/share/lua/5.1) -set(LUAROCKS_CMD env LUA_PATH=${STAGE_EMBEDDED_DIR}/openresty/luajit/share/lua/5.1/?.lua$${STAGE_EMBEDDED_DIR}/openresty/luajit/share/lua/5.1/?/init.lua$$ ${STAGE_EMBEDDED_DIR}/bin/luarocks) +if(ENABLE_DEPLOY_ONLY) + set(LUA_PREFIX ${INSTALL_PREFIX_EMBEDDED}) +else() + set(LUA_PREFIX ${STAGE_EMBEDDED_DIR}) +endif() +set(LUAROCKS_CMD env LUA_PATH=${LUA_PREFIX}/openresty/luajit/share/lua/5.1/?.lua$${LUA_PREFIX}/openresty/luajit/share/lua/5.1/?/init.lua$$ ${LUA_PREFIX}/bin/luarocks) # Where to install development-only dependencies. set(DEV_INSTALL_PREFIX ${WORK_DIR}/dev-env) @@ -60,62 +66,74 @@ function(require_program name) endif() endfunction(require_program) -find_package(LibXml2 REQUIRED) -find_package(PkgConfig REQUIRED) -pkg_search_module(LIBUUID REQUIRED uuid) -pkg_search_module(LIBFFI REQUIRED libffi) -require_program(rsync) - -include(${CMAKE_SOURCE_DIR}/build/cmake/versions.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/dev/nodejs.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/elasticsearch.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/libcidr.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/libgeoip.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/mongodb.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/mora.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/openresty.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/luarocks.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/perp.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/runit_svlogd.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/ruby.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/rsyslog.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/trafficserver.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/static-site.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/core.cmake) -if(ENABLE_HADOOP_ANALYTICS) - include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/flume.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/kylin.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/presto.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/processor.cmake) -endif() +if(ENABLE_DEPLOY_ONLY) + # Create stub/empty targets for things the core build process depends on. But + # for deploy-based builds, we'll assume these dependencies have already been + # installed (since we're assuming the deploys are overlaying a package + # installation). + add_custom_target(bundler) + add_custom_target(libcidr) + add_custom_target(luarocks) + + include(${CMAKE_SOURCE_DIR}/build/cmake/versions.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/core.cmake) +else() + find_package(LibXml2 REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_search_module(LIBUUID REQUIRED uuid) + pkg_search_module(LIBFFI REQUIRED libffi) + require_program(rsync) + + include(${CMAKE_SOURCE_DIR}/build/cmake/versions.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/elasticsearch.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/libcidr.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/libgeoip.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/mongodb.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/mora.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/openresty.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/luarocks.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/perp.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/runit_svlogd.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/ruby.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/rsyslog.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/trafficserver.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/static-site.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/core.cmake) + if(ENABLE_HADOOP_ANALYTICS) + include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/flume.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/kylin.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/presto.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/hadoop-analytics/processor.cmake) + endif() -# -# Testing -# -if(ENABLE_TEST_DEPENDENCIES) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/lua-deps.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/mailhog.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/mongo-orchestration.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/openldap.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/phantomjs.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/shellcheck.cmake) - include(${CMAKE_SOURCE_DIR}/build/cmake/test/unbound.cmake) + # + # Testing + # + if(ENABLE_TEST_DEPENDENCIES) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/lua-deps.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/mailhog.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/mongo-orchestration.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/openldap.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/phantomjs.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/shellcheck.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/unbound.cmake) + endif() + include(${CMAKE_SOURCE_DIR}/build/cmake/test/bundle.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/test/test.cmake) + + # + # Installation + # + include(${CMAKE_SOURCE_DIR}/build/cmake/install.cmake) + + # + # Packaging + # + include(${CMAKE_SOURCE_DIR}/build/cmake/package.cmake) + + # + # Clean Task + # + include(${CMAKE_SOURCE_DIR}/build/cmake/clean-download-archives.cmake) + include(${CMAKE_SOURCE_DIR}/build/cmake/distclean.cmake) endif() -include(${CMAKE_SOURCE_DIR}/build/cmake/test/bundle.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test/test.cmake) - -# -# Installation -# -include(${CMAKE_SOURCE_DIR}/build/cmake/install.cmake) - -# -# Packaging -# -include(${CMAKE_SOURCE_DIR}/build/cmake/package.cmake) - -# -# Clean Task -# -include(${CMAKE_SOURCE_DIR}/build/cmake/clean-download-archives.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/distclean.cmake) diff --git a/build/cmake/core-admin-ui.cmake b/build/cmake/core-admin-ui.cmake index 998c7d33b..26f288c9a 100644 --- a/build/cmake/core-admin-ui.cmake +++ b/build/cmake/core-admin-ui.cmake @@ -1,3 +1,5 @@ +include(${CMAKE_SOURCE_DIR}/build/cmake/dev/nodejs.cmake) + file(GLOB_RECURSE admin_ui_files ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.hbs ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.html diff --git a/build/cmake/core-lua-deps.cmake b/build/cmake/core-lua-deps.cmake index cb3362af4..b59ea8ee6 100644 --- a/build/cmake/core-lua-deps.cmake +++ b/build/cmake/core-lua-deps.cmake @@ -1,7 +1,9 @@ +include(${CMAKE_SOURCE_DIR}/build/cmake/luarocks_install.cmake) + # LuaRock app dependencies luarocks_install(argparse ${LUAROCK_ARGPARSE_VERSION} ${LUAROCK_ARGPARSE_HASH}) luarocks_install(inspect ${LUAROCK_INSPECT_VERSION} ${LUAROCK_INSPECT_HASH}) -luarocks_install(libcidr-ffi ${LUAROCK_LIBCIDR_VERSION} ${LUAROCK_LIBCIDR_HASH} CIDR_DIR=${STAGE_EMBEDDED_DIR} libcidr) +luarocks_install(libcidr-ffi ${LUAROCK_LIBCIDR_VERSION} ${LUAROCK_LIBCIDR_HASH} CIDR_DIR=${LUA_PREFIX} libcidr) luarocks_install(lua-cmsgpack ${LUAROCK_CMSGPACK_VERSION} ${LUAROCK_CMSGPACK_HASH}) luarocks_install(lua-iconv ${LUAROCK_ICONV_VERSION} ${LUAROCK_ICONV_HASH}) luarocks_install(lua-resty-auto-ssl ${LUAROCK_RESTY_AUTO_SSL_VERSION} ${LUAROCK_RESTY_AUTO_SSL_HASH}) diff --git a/build/cmake/deploy/CMakeLists.txt b/build/cmake/deploy/CMakeLists.txt deleted file mode 100644 index 529ca3d43..000000000 --- a/build/cmake/deploy/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) - -# A simplified cmake file that only tries to install the lua dependencies -# needed during a capistrano deployment (when overlaying on top of an package -# install). - -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX /opt/api-umbrella CACHE PATH "default install path" FORCE) -endif() -set(INSTALL_PREFIX_EMBEDDED ${CMAKE_INSTALL_PREFIX}/embedded) -set(EP_BASE work) -set_directory_properties(PROPERTIES EP_BASE ${EP_BASE}) -set(WORK_DIR ${CMAKE_BINARY_DIR}/${EP_BASE}) -set(STAMP_DIR ${WORK_DIR}/stamp) -execute_process(COMMAND mkdir -p ${STAMP_DIR}) -set(VENDOR_DIR ${WORK_DIR}/vendor) -set(VENDOR_LUA_DIR ${VENDOR_DIR}/share/lua/5.1) -set(STAGE_EMBEDDED_DIR ${INSTALL_PREFIX_EMBEDDED}) -set(LUAROCKS_CMD env LUA_PATH=${STAGE_EMBEDDED_DIR}/openresty/luajit/share/lua/5.1/?.lua$${STAGE_EMBEDDED_DIR}/openresty/luajit/share/lua/5.1/?/init.lua$$ ${STAGE_EMBEDDED_DIR}/bin/luarocks) - -include(ExternalProject) - -function(luarocks_install package version) - ExternalProject_Add( - luarock_${package} - DOWNLOAD_COMMAND cd && curl -OL https://luarocks.org/${package}-${version}.rockspec - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${LUAROCKS_CMD} --tree=${VENDOR_DIR} install ${package} ${version} ${ARGV2} - ) -endfunction() - -include(${CMAKE_SOURCE_DIR}/../versions.cmake) -include(${CMAKE_SOURCE_DIR}/../core-lua-deps.cmake) - -add_custom_target( - install-core-lua-deps - DEPENDS ${STAMP_DIR}/core-lua-deps - COMMAND rsync -av ${VENDOR_DIR}/ ${INSTALL_PREFIX_EMBEDDED}/apps/core/shared/vendor/ -) diff --git a/build/cmake/luarocks.cmake b/build/cmake/luarocks.cmake index b0526e9b6..ae8e0adee 100644 --- a/build/cmake/luarocks.cmake +++ b/build/cmake/luarocks.cmake @@ -12,26 +12,3 @@ ExternalProject_Add( COMMAND rm -rf ${VENDOR_DIR}/share/lua ${VENDOR_DIR}/lib/luarocks COMMAND rm -rf ${TEST_VENDOR_DIR}/share/lua ${TEST_VENDOR_DIR}/lib/luarocks ) - -function(_luarocks_install tree_dir package version hash) - ExternalProject_Add( - luarock_${package} - DEPENDS luarocks ${ARGV5} - URL https://luarocks.org/${package}-${version}.rockspec - URL_HASH MD5=${hash} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${LUAROCKS_CMD} --tree=${tree_dir} install ${package} ${version} ${ARGV4} - COMMAND find ${tree_dir} -name *.so -exec chrpath -d {} $ - ) -endfunction() - - -function(luarocks_install package version hash) - _luarocks_install(${VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) -endfunction() - -function(test_luarocks_install package version hash) - _luarocks_install(${TEST_VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) -endfunction() diff --git a/build/cmake/luarocks_install.cmake b/build/cmake/luarocks_install.cmake new file mode 100644 index 000000000..66a5a34de --- /dev/null +++ b/build/cmake/luarocks_install.cmake @@ -0,0 +1,21 @@ +function(_luarocks_install tree_dir package version hash) + ExternalProject_Add( + luarock_${package} + DEPENDS luarocks ${ARGV5} + URL https://luarocks.org/${package}-${version}.rockspec + URL_HASH MD5=${hash} + DOWNLOAD_NO_EXTRACT 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${LUAROCKS_CMD} --tree=${tree_dir} install ${package} ${version} ${ARGV4} + COMMAND find ${tree_dir} -name *.so -exec chrpath -d {} $ + ) +endfunction() + +function(luarocks_install package version hash) + _luarocks_install(${VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) +endfunction() + +function(test_luarocks_install package version hash) + _luarocks_install(${TEST_VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) +endfunction() diff --git a/configure b/configure index 848969dab..d13ddffc1 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ if [ -e "${TOP_SRCDIR}/.configure-custom.sh" ]; then fi PREFIX=/opt/api-umbrella -ENABLE_VARS="hadoop-analytics|on|ENABLE_HADOOP_ANALYTICS test-dependencies|on|ENABLE_TEST_DEPENDENCIES" +ENABLE_VARS="hadoop-analytics|on|ENABLE_HADOOP_ANALYTICS test-dependencies|on|ENABLE_TEST_DEPENDENCIES deploy-only|on|ENABLE_DEPLOY_ONLY" quote() { echo "$1" | sed -e "s|'|'\\\\''|g; 1s/^/'/; \$s/\$/'/" diff --git a/deploy/Gemfile b/deploy/Gemfile index e683c90e4..524b46694 100644 --- a/deploy/Gemfile +++ b/deploy/Gemfile @@ -1,4 +1,5 @@ source "https://rubygems.org" -gem "capistrano", "~> 3.4.0" -gem "dotenv", "~> 2.0.2" +gem "capistrano", "~> 3.6.1" +gem "capistrano-rsync-bladrak", "~> 1.4.2" +gem "dotenv", "~> 2.2.1" diff --git a/deploy/Gemfile.lock b/deploy/Gemfile.lock index 8ca0a08ee..5b3af1052 100644 --- a/deploy/Gemfile.lock +++ b/deploy/Gemfile.lock @@ -1,19 +1,24 @@ GEM remote: https://rubygems.org/ specs: - capistrano (3.4.0) + airbrussh (1.2.0) + sshkit (>= 1.6.1, != 1.7.0) + capistrano (3.6.1) + airbrussh (>= 1.0.0) + capistrano-harrow i18n rake (>= 10.0.0) - sshkit (~> 1.3) - colorize (0.7.7) - dotenv (2.0.2) - i18n (0.7.0) + sshkit (>= 1.9.0) + capistrano-harrow (0.5.3) + capistrano-rsync-bladrak (1.4.2) + capistrano (>= 3.0.0.pre14, < 4) + dotenv (2.2.1) + i18n (0.8.4) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (3.0.1) - rake (10.4.2) - sshkit (1.7.1) - colorize (>= 0.7.0) + net-ssh (4.1.0) + rake (12.0.0) + sshkit (1.13.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) @@ -21,5 +26,9 @@ PLATFORMS ruby DEPENDENCIES - capistrano (~> 3.4.0) - dotenv (~> 2.0.2) + capistrano (~> 3.6.1) + capistrano-rsync-bladrak (~> 1.4.2) + dotenv (~> 2.2.1) + +BUNDLED WITH + 1.15.1 diff --git a/deploy/config/deploy.rb b/deploy/config/deploy.rb index fd5868aa1..c6de0c5b5 100644 --- a/deploy/config/deploy.rb +++ b/deploy/config/deploy.rb @@ -2,10 +2,15 @@ Dotenv.load # config valid only for current version of Capistrano -lock "3.4.0" +lock "3.6.1" set :application, "api-umbrella" -set :repo_url, "https://github.com/NREL/api-umbrella.git" + +# Use rsync to copy the local repo to the servers (rather than checking the +# repo out directly on the server). This allows for the deployments to work +# from custom forks without having to update the URL. +set :scm, :rsync +set :repo_url, "file://#{File.expand_path("../../../", __FILE__)}" # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp @@ -13,9 +18,6 @@ # Default deploy_to directory is /var/www/my_app_name set :deploy_to, "/opt/api-umbrella/embedded/apps/core" -# Default value for :scm is :git -# set :scm, :git - # Default value for :format is :pretty # set :format, :pretty @@ -29,11 +31,7 @@ # set :linked_files, fetch(:linked_files, []).push("config/database.yml", "config/secrets.yml") # Default value for linked_dirs is [] -set :linked_dirs, fetch(:linked_dirs, []).push( - "build/work", - "src/api-umbrella/web-app/public/web-assets", - "vendor" -) +# set :linked_dirs, fetch(:linked_dirs, []).push() # Default value for default_env is {} set :default_env, fetch(:default_env, {}).merge({ @@ -46,57 +44,39 @@ "GEM_PATH" => "/opt/api-umbrella/embedded/lib/ruby/gems/*", "RUBY_ROOT" => "", "RUBYLIB" => "", - - # The real secret tokens are read from the api-umbrella config file when the - # web app is started. But for rake task purposes (like asset precompilation - # where these don't matter), just set some dummy values during deploy. - "RAILS_SECRET_TOKEN" => "TEMP", }) # Default value for keep_releases is 5 set :keep_releases, 15 namespace :deploy do - task :bundle do - on roles(:app) do - within "#{release_path}/src/api-umbrella/web-app" do - execute :bundle, :install, - "--gemfile=#{release_path}/src/api-umbrella/web-app/Gemfile", - "--path=#{shared_path}/vendor/bundle", - '--without="development test"', - "--deployment", - "--clean" - end - end - end - before :updated, :bundle - before :reverted, :bundle - - task :lua_deps do + task :build do on roles(:app) do execute "mkdir", "-p", "#{shared_path}/deploy-build" + # We must wipe cmake's cache file, since the `release_path` changes on # each deployment. execute "rm", "-f", "#{shared_path}/deploy-build/CMakeCache.txt" + + # Run our normal build process, but tweaked slightly for these type of + # live deployments (so it only builds the core application release, and + # does not compile all the software dependencies). within "#{shared_path}/deploy-build" do - execute "cmake", "#{release_path}/build/cmake/deploy" - execute "make", "install-core-lua-deps" + execute "#{release_path}/configure", "--enable-deploy-only" + execute "make" end - end - end - before :updated, :lua_deps - before :reverted, :lua_deps - task :compile_assets do - on roles(:app) do - within("#{release_path}/src/api-umbrella/web-app") do - with "RAILS_ENV" => fetch(:stage) do - execute :bundle, "exec", "rake", "assets:precompile" - end - end + # The normal build process creates a staged version of a new "release". + # Since we're running this inside Capistrano, which has already created a + # release for us, this is a bit funky, but essentially we're going to + # overwrite the current Capistrano release with the staged version from + # the build prprocess (so the release process is consistent regardless of + # whether the release comes from the package or a Capistrano deploy). + execute "rsync", "-a", "-v", "--delete", "#{shared_path}/deploy-build/build/work/stage/opt/api-umbrella/embedded/apps/core/releases/0/", "#{release_path}/" + execute "rsync", "-a", "-v", "--delete", "#{shared_path}/deploy-build/build/work/stage/opt/api-umbrella/embedded/apps/core/shared/vendor/", "#{shared_path}/vendor/" end end - after :updated, :compile_assets + before :updated, :build desc "Reload application" task :reload do diff --git a/docs/developer/deploying.md b/docs/developer/deploying.md index 25bd2ffc0..9541c5354 100644 --- a/docs/developer/deploying.md +++ b/docs/developer/deploying.md @@ -7,35 +7,48 @@ API Umbrella should be installed onto servers using the [binary packages](../get In order to run the deployment scripts, your local computer (or wherever you're deploying from) must have: - git +- rsync - Ruby 1.9+ - Ruby Bundler If you have trouble getting any of these setup locally, you can also run deployments from the [development virtual machine](dev-setup.html), which includes these dependencies. -## First-Time Server Setup +## Initial Server Setup + +### SSH Key Setup On each server you wish to deploy to, you must setup SSH keys so that you can deploy as the `api-umbrella-deploy` user (this user is automatically created as part of the package installation). These steps only need to be performed once per server. -### On Your Computer +- On your computer: + - Ensure you have SSH keys: You must have SSH keys setup on your local computer (or wherever you're deploying from). If you do not have SSH keys, see steps 1 & 2 from GitHub's [Generating SSH keys](https://help.github.com/articles/generating-ssh-keys/) guide for instructions. + - Copy your public key: Copy the contents of your public key (often at `~/.ssh/id_rsa.pub`). For more tips on copying, or alternative locations for your public key, see step 4 from GitHub's [Generating SSH keys](https://help.github.com/articles/generating-ssh-keys/#step-4-add-your-ssh-key-to-your-account) guide. +- On each server: + - With your public SSH key in hand from your own computer, follow these steps on each server, replacing `YOUR_PUBLIC_KEY` as appropriate: + + ```sh + $ echo "YOUR_PUBLIC_KEY" | sudo tee --append /home/api-umbrella-deploy/.ssh/authorized_keys + ``` -- Ensure you have SSH keys: You must have SSH keys setup on your local computer (or wherever you're deploying from). If you do not have SSH keys, see steps 1 & 2 from GitHub's [Generating SSH keys](https://help.github.com/articles/generating-ssh-keys/) guide for instructions. -- Copy your public key: Copy the contents of your public key (often at `~/.ssh/id_rsa.pub`). For more tips on copying, or alternative locations for your public key, see step 4 from GitHub's [Generating SSH keys](https://help.github.com/articles/generating-ssh-keys/#step-4-add-your-ssh-key-to-your-account) guide. +### Install Build Dependencies -### On Each Server +On each server you wish to deploy to, you must install the system packages needed for building dependencies (for example, make, gcc, etc). This can be automated through the `build/scripts/install_build_dependencies` shell script: -- With your public SSH key in hand from your own computer, follow these steps on each server, replacing `YOUR_PUBLIC_KEY` as appropriate: +- On each server: ```sh - $ echo "YOUR_PUBLIC_KEY" | sudo tee --append /home/api-umbrella-deploy/.ssh/authorized_keys + $ curl -OLJ https://github.com/NREL/api-umbrella/archive/master.tar.gz + $ tar -xvf api-umbrella-master.tar.gz + $ cd api-umbrella-master + $ sudo ./build/scripts/install_build_dependencies ``` ## Deploying -- First-time setup: +- One-time local setup: - Check out the [api-umbrella](https://github.com/NREL/api-umbrella) repository from git: ```sh - $ git clone https://github.com/NREL/api-umbrella-router.git router + $ git clone https://github.com/NREL/api-umbrella.git ``` - Install the deployment dependencies from inside the `deploy` directory: @@ -45,7 +58,7 @@ On each server you wish to deploy to, you must setup SSH keys so that you can de $ bundle install ``` - - Define your destination servers: Add a `.env` file inside the `router` directory defining the servers to deploy to for the "staging" or "production" environments: + - Define your destination servers: Add a `.env` file inside the `api-umbrella/deploy` directory defining the servers to deploy to for the "staging" or "production" environments: ``` API_UMBRELLA_STAGING_SERVERS="10.0.0.1,10.0.0.2"