putpaws 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +23 -3
- data/lib/putpaws/provision/preset.rb +2 -0
- data/lib/putpaws/provision/presets/rails/preset.json +35 -0
- data/lib/putpaws/provision/presets/rails/templates/taskdef-app.json.erb +33 -0
- data/lib/putpaws/provision/tasks/provision.rake +4 -2
- data/lib/putpaws/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6d053460a5c78abad1e20f800e26aae412b0768b47a182380c9e876ebb616f9
|
|
4
|
+
data.tar.gz: bbb6cd4158d334b4029b17cb6141cf52e6e490317f9d438d2af0d43856876728
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdf0ff9f7a76d786532fe1b4a13991bd0542d2d584c9a1158996ff84f0479913062cc8b5ce9856a27fe3b7d83978e3c6d9e8816753733ac0a43db9e20ea9986b
|
|
7
|
+
data.tar.gz: b3714483e120918f2c777b1dd8f0b010efc4f26268a283a9f1d1a426f0ea0e1b214c033b2fb0e19d2c5b77a498a22f373a994c8ad16620a792993b528e6faa37
|
data/README.md
CHANGED
|
@@ -49,6 +49,26 @@ Presets are searched in this order: project local (`.putpaws/provisioning/preset
|
|
|
49
49
|
user global (directories in `PUTPAWS_PRESETS_PATH`, then `~/.putpaws/presets/`), and the ones bundled in the gem.
|
|
50
50
|
Whichever you pick on `ready` is copied into the project so the project owns its snapshot.
|
|
51
51
|
|
|
52
|
+
Bundled presets (ECS Fargate, `awsvpc`):
|
|
53
|
+
|
|
54
|
+
- `rails` (default) ... one `app` container on port 8080. Assumes the Rails 8 default Dockerfile,
|
|
55
|
+
where [Thruster](https://github.com/basecamp/thruster) fronts Puma and does what an nginx sidecar used to
|
|
56
|
+
(HTTP/2, asset caching / compression, X-Sendfile); TLS terminates at the ALB.
|
|
57
|
+
Thruster listens on port 80 by default, but the Rails Dockerfile runs as a non-root user and
|
|
58
|
+
Fargate does not let non-root processes bind ports below 1024 (unlike local Docker, which sets
|
|
59
|
+
`net.ipv4.ip_unprivileged_port_start=0`), so the preset sets `HTTP_PORT=8080` and
|
|
60
|
+
`container_port: 8080`; point the ALB target group at 8080. The Dockerfile needs no change
|
|
61
|
+
(`EXPOSE 80` is metadata only). Older Rails apps work too by adding the `thruster` gem and
|
|
62
|
+
starting with `bin/thrust bin/rails server`, or by setting `container_port` to the Puma port
|
|
63
|
+
and dropping `HTTP_PORT`.
|
|
64
|
+
- `rails-nginx` ... same `app` task definition plus a `web` one with an nginx sidecar on port 80.
|
|
65
|
+
The sidecar is a stock nginx image with no proxy config, so point `nginx_image` at your own image
|
|
66
|
+
that proxies to `localhost:3000`. Keep this only when you need something Thruster does not do
|
|
67
|
+
(maintenance pages, custom rewrites, proxy-level auth).
|
|
68
|
+
|
|
69
|
+
Need another task definition (Ex: a batch worker)? Add an entry to `task_definitions` of the
|
|
70
|
+
copied preset with its own template; `up` creates it and writes an `application.json` entry for it.
|
|
71
|
+
|
|
52
72
|
Security groups are either specified (one or more existing ones; putpaws never touches their rules)
|
|
53
73
|
or a new one is created for the service when left empty on `ready`.
|
|
54
74
|
|
|
@@ -60,8 +80,8 @@ family `{service_name}-{suffix}` (Ex: `awesome-api-staging-app` / `awesome-api-s
|
|
|
60
80
|
each pointing at the `infra.target` of the same name. Only the entry of the preset's
|
|
61
81
|
`service_task_definition` carries `service` (for `ecs:deploy` / `ecs:attach`); the others have
|
|
62
82
|
`service: null` and are meant for one-off tasks (`ecs:run` / `ecs:shell` / scheduler),
|
|
63
|
-
so `db:migrate` keeps running on the plain `app` task definition
|
|
64
|
-
runs `web` (nginx + app). `infra.network` is written once as `{service_name}`.
|
|
83
|
+
so with `rails-nginx` `db:migrate` keeps running on the plain `app` task definition while the
|
|
84
|
+
service runs `web` (nginx + app). `infra.network` is written once as `{service_name}`.
|
|
65
85
|
Existing keys are never deleted; remove stale ones by hand.
|
|
66
86
|
Secrets are handled by reference only: task definitions point to existing
|
|
67
87
|
SSM parameters (Ex: `/{service_name}/RAILS_MASTER_KEY`) and putpaws never touches the values.
|
|
@@ -72,7 +92,7 @@ so `scheduler:deploy` works any time by just writing `.putpaws/schedule.json`.
|
|
|
72
92
|
The CPU architecture is declared once as `cpu_architecture` (`ARM64` / `X86_64`) in the preset
|
|
73
93
|
defaults (overridable per service via `overrides`), and applied consistently to both
|
|
74
94
|
task definitions (`runtimePlatform`) and CodeBuild (environment type and image).
|
|
75
|
-
The bundled
|
|
95
|
+
The bundled presets default to `ARM64`; projects whose copied preset predates this setting
|
|
76
96
|
fall back to `X86_64` so nothing changes silently. When switching an existing service to ARM,
|
|
77
97
|
run the CI build right after `up` so an ARM image exists before tasks roll
|
|
78
98
|
(`devops.environment_type` / `environment_image` can override the derivation for staged migration).
|
|
@@ -6,6 +6,8 @@ module Putpaws
|
|
|
6
6
|
module Provision
|
|
7
7
|
class Preset
|
|
8
8
|
BUILTIN_DIR = File.expand_path('presets', __dir__)
|
|
9
|
+
# Preselected on `ready`: Rails 8 with Thruster, app container only.
|
|
10
|
+
DEFAULT = 'rails'
|
|
9
11
|
|
|
10
12
|
def self.local_dir(path_prefix: '.putpaws')
|
|
11
13
|
Pathname.new(path_prefix).join('provisioning', 'presets')
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"defaults": {
|
|
3
|
+
"cpu_architecture": "ARM64",
|
|
4
|
+
"cpu": "256",
|
|
5
|
+
"memory": "512",
|
|
6
|
+
"desired_count": 1,
|
|
7
|
+
"container_port": 8080,
|
|
8
|
+
"log_retention_days": 30,
|
|
9
|
+
"image_tag": "latest",
|
|
10
|
+
"assign_public_ip": "DISABLED",
|
|
11
|
+
"env": {
|
|
12
|
+
"RAILS_ENV": "production",
|
|
13
|
+
"RACK_ENV": "production",
|
|
14
|
+
"RAILS_LOG_TO_STDOUT": "1",
|
|
15
|
+
"HTTP_PORT": "8080"
|
|
16
|
+
},
|
|
17
|
+
"secrets": {
|
|
18
|
+
"RAILS_MASTER_KEY": "{ssm_parameter_prefix}/RAILS_MASTER_KEY"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"task_definitions": [
|
|
22
|
+
{ "suffix": "app", "template": "taskdef-app.json.erb", "container_name": "app" }
|
|
23
|
+
],
|
|
24
|
+
"service_task_definition": "app",
|
|
25
|
+
"devops_defaults": {
|
|
26
|
+
"source_type": "GITHUB",
|
|
27
|
+
"environment_images": {
|
|
28
|
+
"ARM64": "aws/codebuild/amazonlinux-aarch64-standard:3.0",
|
|
29
|
+
"X86_64": "aws/codebuild/standard:7.0"
|
|
30
|
+
},
|
|
31
|
+
"compute_type": "BUILD_GENERAL1_SMALL",
|
|
32
|
+
"privileged_mode": true,
|
|
33
|
+
"buildspec": "buildspec.yml"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"family": "<%= service_name %>-app",
|
|
3
|
+
"requiresCompatibilities": ["FARGATE"],
|
|
4
|
+
"networkMode": "awsvpc",
|
|
5
|
+
"runtimePlatform": {
|
|
6
|
+
"cpuArchitecture": "<%= cpu_architecture %>",
|
|
7
|
+
"operatingSystemFamily": "LINUX"
|
|
8
|
+
},
|
|
9
|
+
"cpu": "<%= cpu %>",
|
|
10
|
+
"memory": "<%= memory %>",
|
|
11
|
+
"executionRoleArn": "<%= execution_role_arn %>",
|
|
12
|
+
"taskRoleArn": "<%= task_role_arn %>",
|
|
13
|
+
"containerDefinitions": [
|
|
14
|
+
{
|
|
15
|
+
"name": "app",
|
|
16
|
+
"image": "<%= image %>",
|
|
17
|
+
"essential": true,
|
|
18
|
+
"portMappings": [
|
|
19
|
+
{ "containerPort": <%= container_port %>, "protocol": "tcp" }
|
|
20
|
+
],
|
|
21
|
+
"environment": <%= env_json %>,
|
|
22
|
+
"secrets": <%= secrets_json %>,
|
|
23
|
+
"logConfiguration": {
|
|
24
|
+
"logDriver": "awslogs",
|
|
25
|
+
"options": {
|
|
26
|
+
"awslogs-group": "<%= log_group %>",
|
|
27
|
+
"awslogs-region": "<%= region %>",
|
|
28
|
+
"awslogs-stream-prefix": "app"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -22,8 +22,10 @@ namespace :provision do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
region = prompt.ask("Region:", default: 'ap-northeast-1')
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
preset_catalog = Putpaws::Provision::Preset.catalog
|
|
26
|
+
preset_choices = preset_catalog.map{|e| ["#{e[:name]} (#{e[:source]})", e[:name]]}.to_h
|
|
27
|
+
preset_default = (preset_catalog.index{|e| e[:name] == Putpaws::Provision::Preset::DEFAULT} || 0) + 1
|
|
28
|
+
preset_name = prompt.select("Preset:", preset_choices, default: preset_default)
|
|
27
29
|
|
|
28
30
|
puts "--- Basic infra (existing resources; used to generate IAM policies) ---"
|
|
29
31
|
vpc_id = prompt.ask("VPC ID:"){|q| q.required(true)}
|
data/lib/putpaws/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: putpaws
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- metheglin
|
|
@@ -182,6 +182,8 @@ files:
|
|
|
182
182
|
- lib/putpaws/provision/presets/rails-nginx/preset.json
|
|
183
183
|
- lib/putpaws/provision/presets/rails-nginx/templates/taskdef-app.json.erb
|
|
184
184
|
- lib/putpaws/provision/presets/rails-nginx/templates/taskdef-web.json.erb
|
|
185
|
+
- lib/putpaws/provision/presets/rails/preset.json
|
|
186
|
+
- lib/putpaws/provision/presets/rails/templates/taskdef-app.json.erb
|
|
185
187
|
- lib/putpaws/provision/provision_config.rb
|
|
186
188
|
- lib/putpaws/provision/provision_task.rb
|
|
187
189
|
- lib/putpaws/provision/resources/base.rb
|