Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8db9918

Browse files
committed
First commit
0 parents  commit 8db9918

23 files changed

+609
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.gem
2+
/Gemfile.lock

.rubocop.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Documentation:
2+
Enabled: false
3+
Layout/LineLength:
4+
Max: 120
5+
Metrics/BlockLength:
6+
Enabled: false
7+
Style/MultilineBlockChain:
8+
Enabled: false
9+
Style/WordArray:
10+
Enabled: false
11+
Style/ClassAndModuleChildren:
12+
Enabled: false
13+
Bundler/OrderedGems:
14+
Enabled: false
15+
Style/SymbolArray:
16+
Enabled: false

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: ruby
2+
3+
rvm:
4+
- 2.5.7
5+
- 2.6.6
6+
- 2.7.1
7+
- 3.0.0
8+
9+
before_install:
10+
- yes | gem update --system --force
11+
- gem install bundler
12+
- bundle install --jobs=3 --retry=3
13+
14+
script:
15+
- bundle exec rspec

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project made by Monade Team are documented in this file. For info refer to team@monade.io
3+
4+
## [0.1.0-alpha] - 2021-03-21
5+
First functional version
6+
7+
### Added
8+
- README
9+
- CHANGELOG
10+
- LICENSE
11+
- tests

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "https://rubygems.org"
2+
gemspec
3+
4+
gem 'solargraph'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Mònade srl, Piero Dotti
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[![Build Status](https://travis-ci.org/monade/ecs-deploy-cli.svg?branch=master)](https://travis-ci.org/monade/ecs-deploy-cli)
2+
3+
# ECS Deploy CLI
4+
5+
A CLI + DSL to simplify deployments on ECS.
6+
7+
It's partial, incomplete and unstable, DON'T use yet.
8+
9+
## Installation
10+
11+
Simply add the gem to your Gemfile
12+
13+
```ruby
14+
gem 'ecs-deploy-cli', github: 'monade/ecs-deploy-cli'
15+
```
16+
17+
## Usage
18+
19+
First, define a ECSFile in your project, to design your ECS cluster.
20+
21+
**The cluster and the service must be already there!**
22+
23+
Example of a Rails app on ECS:
24+
```ruby
25+
aws_profile_id ENV['AWS_PROFILE_ID']
26+
aws_region ENV['AWS_REGION']
27+
28+
repository ENV['REPO_URL']
29+
version ENV['CURRENT_VERSION']
30+
31+
cluster ''
32+
33+
# This is used as a template for the next two containers, it will not be used inside a task
34+
container :base_container do
35+
load_envs 'envs/base.yml'
36+
load_envs 'envs/production.yml'
37+
secret key: 'RAILS_MASTER_KEY', value: 'railsMasterKey' # Taking the secret from AWS System Manager
38+
working_directory '/app'
39+
cloudwatch 'yourproject' # Configuring cloudwatch logs
40+
end
41+
42+
# The rails web application
43+
container :web, extends: :base_container do
44+
cpu 512
45+
memory limit: 3584, reservation: 3584
46+
command 'bundle', 'exec', 'puma', '-C', 'config/puma.rb'
47+
48+
expose host_port: 0, protocol: 'tcp', container_port: 3000
49+
end
50+
51+
# The rails job worker
52+
container :worker, extends: :base_container do
53+
cpu 1536
54+
memory limit: 3584, reservation: 3584
55+
command 'bundle', 'exec', 'shoryuken', '-C', 'config/shoryuken.yml', '-R'
56+
end
57+
58+
# A container to exec cron jobs
59+
container :cron, extends: :base_container do
60+
command 'rails', 'runner'
61+
end
62+
63+
# The main task, having two containers
64+
task :yourproject do
65+
containers :web, :worker
66+
cpu 2048
67+
memory 3584
68+
69+
tag 'product', 'yourproject'
70+
end
71+
72+
# The main service
73+
service :'yourproject-service' do
74+
task :yourproject
75+
end
76+
77+
# A task for cron jobs
78+
task :'yourproject-cron' do
79+
containers :cron
80+
cpu 256
81+
memory 1024
82+
83+
tag 'product', 'yourproject'
84+
end
85+
86+
# Scheduled tasks using Cloudwatch Events / Eventbridge
87+
cron :scheduled_emails do
88+
task :'yourproject-cron' do
89+
# Overrides
90+
container :web do
91+
command 'rails', 'cron:exec'
92+
end
93+
end
94+
# Examples:
95+
# every 1.hour
96+
run_at '0 * * * ? *'
97+
end
98+
```
99+
100+
Now create your deploy script:
101+
```ruby
102+
require 'ecs_deploy_cli'
103+
104+
configuration = EcsDeployCli::FileParser.load('ECSFile')
105+
# This will update all your services and tasks to fit the new configuration
106+
configuration.apply!
107+
```
108+
109+
### TODOs
110+
111+
- Scheduled tasks implementation
112+
- More configuration options
113+
- Create the service if not present
114+
- An actual CLI using Thor
115+
- Specs

Rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
namespace :gem do
3+
task :release do
4+
desc 'Releases the gem'
5+
6+
filename = `gem build ecs-deploy-cli.gemspec 2> /dev/null | grep -E 'File:'`.split(' ').last
7+
`gem push #{filename}`
8+
end
9+
end

ecs-deploy-cli.gemspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.push File.expand_path('lib', __dir__)
4+
require 'ecs_deploy_cli/version'
5+
6+
Gem::Specification.new do |s|
7+
s.name = 'ecs_deploy_cli'
8+
s.version = EcsDeployCli::VERSION
9+
s.date = '2021-03-31'
10+
s.summary = "A Command line interface to make ECS deploys more simple"
11+
s.description = "A Command line interface to make ECS deploys more simple"
12+
s.authors = ['Mònade']
13+
s.email = 'team@monade.io'
14+
s.files = Dir['lib/**/*']
15+
s.test_files = Dir['spec/**/*']
16+
s.required_ruby_version = '>= 2.5.0'
17+
s.homepage = 'https://rubygems.org/gems/ecs_deploy_cli'
18+
s.license = 'MIT'
19+
s.add_dependency 'activesupport', ['>= 5', '< 7']
20+
s.add_dependency 'aws-sdk-ecs'
21+
s.add_development_dependency 'rspec', '~> 3'
22+
s.add_development_dependency 'rubocop'
23+
end

0 commit comments

Comments
 (0)