Giter Site home page Giter Site logo

justintime50 / srvinfra Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 23 KB

srvinfra is a tool to deploy, update, and maintain services and websites on a server hosted by Docker.

License: MIT License

Shell 100.00%
srvinfra infra deploy update service website server hosted docker srv

srvinfra's Introduction

srvinfra

srvinfra is a tool to deploy, update, and maintain Docker projects hosted on a server.

Build Version Licence

Showcase

I store all my Docker services in the same place and have similar commands to update and deploy them but found myself needing to constantly navigate all over the filesystem to run Docker commands. With srvinfra, I can deploy and manage my services with ease from anywhere using a unified CLI syntax.

srvinfra will stash any local changes of a project, pull down new changes via git, then deploy the service via Docker. For services that have a production configuration, it will need to be titled docker-compose-prod.yaml and have a normal docker-compose.yaml file as well. Either .yml or .yaml extensions are supported. When a service does not have a production configuration, srvinfra will deploy using the base config.

Install

# Setup the tap
brew tap justintime50/formulas

# Install srvinfra
brew install srvinfra

NOTE: srvinfra assumes Docker Compose v2 is installed.

Once you have srvinfra installed, you'll need to setup an environment variable:

echo 'export SRVINFRA_SERVICES_DIR=path/to/dir' >> ~/.zshrc

You can change the database executable used from mysql to mariadb by setting it via the SRVINFRA_DATABASE_EXECUTABLE env var:

echo 'export SRVINFRA_DATABASE_EXECUTABLE=mariadb' >> ~/.zshrc

Usage

NOTE: You may need to quote ROOT_PASSWORD in the commands below.

# Deploy a service (relative from $SRVINFRA_SERVICES_DIR), subdirectories are possible
srvinfra deploy justintime50/justinpaulhammond
srvinfra deploy justintime50/server-infra/plex

# Deploy all services (great for server cold-start)
srvinfra deploy_all

# Decrypt a compressed SQL backup file
# The BACKUP_SECRET is assumed to be the same as the database ROOT_PASSWORD
srvinfra decrypt_database_backup PATH_TO_SQL_FILE BACKUP_SECRET

# Export a SQL database from a Docker container, unencrypted and uncompressed
# Default PATH_TO_SQL_FILE: './database.sql'
srvinfra export_database DATABASE_CONTAINER_NAME ROOT_PASSWORD DATABASE_NAME PATH_TO_SQL_FILE

# Export a compressed SQL database from a Docker container and encrypt the backup (recommended)
# Default PATH_TO_SQL_FILE: './database.enc.gz'
srvinfra export_database_secure DATABASE_CONTAINER_NAME ROOT_PASSWORD DATABASE_NAME PATH_TO_SQL_FILE

# Import a SQL database to a Docker container
srvinfra import_database DATABASE_CONTAINER_NAME ROOT_PASSWORD DATABASE_NAME PATH_TO_SQL_FILE

# Import an encrypted & compressed SQL database to a Docker container (command combines `decrypt_database_backup` and `import_database` commands)
# ROOT_PASSWORD is assumed to be the same as the database root password
srvinfra import_encrypted_database DATABASE_CONTAINER_NAME ROOT_PASSWORD DATABASE_NAME PATH_TO_SQL_FILE

# Get the status of a Docker container by name
srvinfra status justinpaulhammond

# Update a service
srvinfra update justintime50/server-infra/plex

# Update all services
srvinfra update_all

# View all available commands
srvinfra help

Development

# Lint the project
shellcheck src/srvinfra.sh

srvinfra's People

Contributors

justintime50 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

srvinfra's Issues

Pull Git Repos During Deploy Command

The one thing that would make this tool ideal is to complete it by making a git stash && git pull step happens during the deploy command. This would allow someone to completely deploy a new copy of a project without needing extra commands.

Importing a Database Doesn't Work if it Has Dashes in the Container Name

Importing a database to all-the-invites-alltheinvites-db-1 doesn't work because we cut at the first dash currently which is fine for services without a dash in the name but this service has a dash so we cut and try looking for a container with the name of all which doesn't work.

This needs to be fixed to allow for better cutting (preferred so it's dynamic) or allow the user to specify what DB to pass in.

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.