Built with;
Create a script that helps the developer to dockerize their applications, deploy it locally or push to a remote container registry.
Provide a MySQL or MongoDB database service with Docker Compose in addition to the application.1
Script has to be able to ;
- Build and run docker images.
- Push the image to the Docker Hub or Gitlab Container Registry.
- Limit machine resources like CPU and memory if relevant arguments are given. (Default is limitless)
- Deploy additional services like MySQL or Mongo Database with Docker Compose.
📔 Overview 🔝
This repository contains an assignment project developed under the Patika.dev & Protein DevOps Engineer Bootcamp. Bootstrapper
is an initializer script that sets up the machine as instructed. Sailboat
is the main script that is coded by the terms of the project.
✨ Features 🔝
- Sets the timezone of the machine as UTC+3 (Europe/Istanbul) and enables Network Time Protocol.
- Downloads the latest package information.
- Downloads, installs, and configures Docker Engine and Docker Compose.
- Sets the permissions of the script files.
- Defines a system-wide alias of the main script for easy use.
- Has three modes: Build, Deploy, and Template.
- Build and deploy modes may take additional arguments like image name and image tag to define image properties.
- Build mode may also take "--registry" argument which will cause re-tag the image with the defined username.
- The re-tagged image will be pushed to the specified container registry.
- With deploy mode, you may also name your container and set CPU and memory limits.
- Template mode will assist the user with predefined database services in addition to the main image.
- Docker-compose is used in template mode with pre-defined database services are MySQL and MongoDB.
⚙️ Installation 🔝
- Install VirtualBox and Vagrant to your machine if you do not have them.
- Clone the project to your machine.
- Open your CLI, change directory to project directory, and type
vagrant up
. - Vagrant will configure the virtual machine first then you may test the project.
- Download all of the project files.
- Copy all scripts under the
/shared/scripts
and sample project from/shared/projects/python
to your environment. - Execute
bootstrap.sh
first to configure the machine. - Make sure your environment has a Docker installation too.
- Run the scripts with the aliases configured or manually from the directories that are stated below.
🔧 Usage 🔝
- Built-in alias is
sailboat
You may use it if you executedbootstrap.sh
first. - Optionally, you may call the scripts from any directory with an acceptable arguments that are stated below.
- The target directory of Sailboat script is
/opt/projects/python
directory. - You can change these settings by re-defining the
TARGET_DIR
variable within the configuration file of the script.
OPTIONS: ARGUMENTS: DESCRIPTION: OBLIGATION:
-m | --mode <build|deploy|template> Mode selection. Mandatory for ALL modes.
-n | --image-name <image-name> Docker image name. Mandatory for BUILD and DEPLOY modes.
-t | --image-tag <image-tag> Docker image tag. Mandatory for BUILD and DEPLOY modes.
-r | --registry <dockerhub|gitlab> Docker Hub or GitLab Registry. Optional for BUILD Mode.
-c | --container-name <container-name> Container name. Optional for DEPLOY mode.
-p | --cpu <cpu-limit> Container CPU limit Optional for DEPLOY mode.
-s | --memory <memory-limit> Container memory limit. Optional for DEPLOY mode.
-a | --application-name <mongo|mysql> Run MySQL or MongoDB server. Mandatory for TEMPLATE mode.
-h | --help Shows this help message.
💻 Technologies 🔝
- Linux
- Bash Scripting
- Docker ❤️
- Oracle VM VirtualBox
- Vagrant by HashiCorp
📂 Directories 🔝
Scripts : /opt/scripts
Configurations : /opt/scripts/configs
Sample Project : /opt/projects/python
💾 Submitted Assignment 🔝
You may check out the submitted version of this project here.
Footnotes
-
A simple Python application(flask) is provided as a sample project and the script is built upon this configuration. (Can be modified to any other project) ↩