GithubHelp home page GithubHelp logo

akecel / deploy-shell-script Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 17 KB

Simple shell scripts to easily deploy your applications on a web server.

License: MIT License

Shell 100.00%
ssh script deployment devops tutorial beginner-friendly

deploy-shell-script's Introduction

Deploy Shell Script 🚀

Simple shell scripts to easily deploy your applications on a web server. This deployment technique separates your web server from your remote git, it offers additional security, as well as increased scalability. Moreover, this process will be the same regardless of the server.

Requirement

  • Github or GitLab repository
  • Web server
  • Ability to use SSH on your server

Configuration

For the exemple we are going to take a simple repo on github : simple_test_repo.

  • First, connect to you server with ssh :
  • Go in the srv directory :
cd /srv
  • Create a src directory :
sudo mkdir src
  • Give permission to the user :
sudo chown user:user src
  • Go into the src directory :
cd src
  • Clone your Github répo (you can use ssh clone if you have configurate ssh keys) :
git clone https://github.com/user/simple_test_repo.git
  • Check if the clone work well :
ls
  • Create a scripts directory and go in :
sudo mkdir scripts
&&
cd scripts
  • Create a sh script :
nano pull_and_deploy_website.sh
  • Past this in and custumize it for your path :
!#/bin/bash
cd /srv/src/simple_test_repo
git pull
rsync -r . /var/www/html --exclude .git
  • Give permission to the script :
chmod +x pull_and_deploy_website.sh

You have finished with the basic configuration, you can of course adapt all this to your needs. For a first deployment it is strongly recommended to add your configuration files only in var/html/www and not in src.

Usage

  • Excecute :
srv/src/scripts/pull_and_deploy_website.sh

This will execute your script and all the commands found there, in the event of an error it will display the error of the command in question. During the process (git pull) it will ask you for your Github or Gitlab credentials, to avoid this, use an ssh key.

Customization

You can of course customize this script by adding any configuration, build or test command, you can very well integrate this script into a pipeline for a simple and secure CD.

It is even advisable to separate this script into three parts :

The first one for the git pull :

!#/bin/bash
cd /srv/src/simple_test_repo
git pull

A second one for copying :

!#/bin/bash
cd /srv/src/simple_test_repo
rsync -r . /var/www/html --exclude .git

And a third to execute the two previous ones :

!#/bin/bash
/srv/src/scripts/pull_website.sh
/srv/src/scripts/deploy_website.sh

It depends only on you how you want to scale your deployment :octocat:

deploy-shell-script's People

Contributors

akecel avatar

Watchers

 avatar  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.