Coder Social home page Coder Social logo

mina-dotenv's Introduction

Mina-dotenv

โšซ Dotenv plugin for mina.

Alleviate the need to SSH to your server and setup an .env file manually there. This plugin simply copies your local .env to your server ๐Ÿ˜‹

Installation

To use it in your project's deployment process install this gem with the following command:

gem install mina-dotenv

Add the following line to your deploy.rb script:

require 'mina/dotenv'

This enables you to use the dotenv:push task in your deploy script.

To automatically push your .env file to the server add this line to your deploy task:

invoke :'dotenv:push'

Configuration

Your development machine and your server will often need different keys to run your app. Therefore a :dotenv_location variable exist to define which .env file to push to the server.

Important: The :dotenv_location defaults to .env

To change which .env file to push add this line your deploy.rb file:

set :dotenv_location, '.server_env'

Example deploy script

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
require 'mina/dotenv' # <---- Added this line

set :domain, 'my-page.com'
set :deploy_to, '/home/deploy/www/...'
set :repository, 'https://github.com/...'
set :branch, 'master'
set :dotenv_location, '.server_env' # <--- Added this line

...

desc "Deploys the current version to the server."
task :deploy => :environment do
  to :before_hook do
  end

  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'dotenv:push' # <----- Added this line
    invoke :'bundle:install'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
    end
  end
end

What it does

Push

The push task will look for the '.env' file specified in the :dotenv_location variable. If found it will copy it's content and echo it to an .env file located in the shared folder location you your app's deploy location. And symlink it to the root of the newest release.

If no local .env file is found a blank one will be created on the server.

Pull

The pull task uses scp to retrieve the .env file from the server.

Note: It will take all configuration from your deploy.rb file!

Important: It will add the downloaded file to your .gitignore file!

It is intended to be used from the terminal like this:

mina dotenv:pull

Contribution

If you have ideas or feature requests please feel free to open an issue on this Github page. Pull requests are welcome also ๐Ÿ˜„

mina-dotenv's People

Contributors

dostro avatar monorkin avatar

Watchers

James Cloos avatar

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.