shipitron 1.0.1 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +1 -0
  3. data/.gitattributes +1 -0
  4. data/.gitignore +1 -0
  5. data/Dockerfile +28 -8
  6. data/Dockerfile.release +25 -3
  7. data/Gemfile +1 -0
  8. data/README.md +48 -9
  9. data/build_dev.sh +1 -1
  10. data/docker-compose.yml +24 -0
  11. data/lib/shipitron/cli.rb +33 -3
  12. data/lib/shipitron/client.rb +9 -0
  13. data/lib/shipitron/client/bootstrap_application.rb +1 -0
  14. data/lib/shipitron/client/create_ecs_services.rb +1 -0
  15. data/lib/shipitron/client/deploy_application.rb +1 -0
  16. data/lib/shipitron/client/ensure_deploy_not_running.rb +2 -1
  17. data/lib/shipitron/client/fetch_clusters.rb +1 -0
  18. data/lib/shipitron/client/force_deploy.rb +58 -0
  19. data/lib/shipitron/client/load_application_config.rb +4 -0
  20. data/lib/shipitron/client/load_templates.rb +1 -0
  21. data/lib/shipitron/client/register_ecs_task_definitions.rb +1 -0
  22. data/lib/shipitron/client/run_ecs_tasks.rb +14 -1
  23. data/lib/shipitron/docker_image.rb +4 -1
  24. data/lib/shipitron/find_docker_volume_name.rb +68 -0
  25. data/lib/shipitron/git_info.rb +57 -0
  26. data/lib/shipitron/s3_copy.rb +46 -0
  27. data/lib/shipitron/server/deploy_application.rb +3 -0
  28. data/lib/shipitron/server/docker/build_image.rb +4 -1
  29. data/lib/shipitron/server/docker/configure.rb +46 -10
  30. data/lib/shipitron/server/docker/push_image.rb +3 -0
  31. data/lib/shipitron/server/docker/run_build_script.rb +17 -10
  32. data/lib/shipitron/server/download_build_cache.rb +17 -4
  33. data/lib/shipitron/server/git/clone_local_copy.rb +3 -4
  34. data/lib/shipitron/server/git/update_cache.rb +1 -0
  35. data/lib/shipitron/server/run_post_build.rb +40 -1
  36. data/lib/shipitron/server/transform_cli_args.rb +6 -0
  37. data/lib/shipitron/server/update_ecs_task_definitions.rb +2 -1
  38. data/lib/shipitron/server/upload_build_cache.rb +14 -8
  39. data/lib/shipitron/version.rb +1 -1
  40. data/scripts/docker-entrypoint.sh +9 -0
  41. data/shipitron.gemspec +8 -6
  42. metadata +50 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68328f7af2efc2a7d163280f0bb1613d685d85b09f991cc53061a5286c02c66e
4
- data.tar.gz: a349443e9f92c64101ebc272f44cfd8b5256d69c83b693b303eed1c2c50ff279
3
+ metadata.gz: c1f02ed921fdb5107cebc789f0554daac22d275024e50b94f6059d0ab6d996c1
4
+ data.tar.gz: 65e5fbca1de1090e34178d44244a5e30938b7de80fe17f0ea7b3df9510e54f9a
5
5
  SHA512:
6
- metadata.gz: a226f3113f356b9a475b3b64aeb9d9ccebf8598d56a29ca99e71dbe7df6c00091abdbd35e70f81c9e0913aa014547c487eb66d221249a327b41220eafac09bb9
7
- data.tar.gz: ac68f08e8ef8ba579d081538ac32930c723d324e5b89c3a67c5963ffa762daeb90665e08c80d3e236646dcf4178cf1b9096489f5aabf18f784cb66448cbb16b5
6
+ metadata.gz: 14d5f5e245ab946538ab1aee9b5d88d88fafb7d4baa61c3634d165d42acfcf5a83e0231cc9299f37d37d38da9a96be0dfc04ba77b42499fc36bdcc5acf69980c
7
+ data.tar.gz: ace846368647ec022343af65af9978f2647aa7113de1795900a18091754e34e26657bd4d4d4be10e60f4bef81baffa886917c79537f834377182eadabb4a704e
@@ -2,3 +2,4 @@
2
2
  /pkg/
3
3
  Gemfile.lock
4
4
  /tmp/
5
+ /spec/fixtures/test_repo
@@ -0,0 +1 @@
1
+ spec/fixtures/test_repo.tgz filter=lfs diff=lfs merge=lfs -text
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  /tmp/
5
5
  /cache/
6
+ /spec/fixtures/test_repo
data/Dockerfile CHANGED
@@ -1,35 +1,55 @@
1
- FROM ruby:2.5.0-alpine3.7 as cache
1
+ FROM ruby:2.7.1-alpine as cache
2
2
  COPY cache/ /tmp/
3
3
  RUN cd /usr/local/bundle && \
4
4
  ([ -f /tmp/bundler-data.tar.gz ] && \
5
5
  tar -zxf /tmp/bundler-data.tar.gz && \
6
6
  rm /tmp/bundler-data.tar.gz) || true
7
7
 
8
- FROM ruby:2.5.0-alpine3.7
9
- MAINTAINER Ryan Schlesinger <ryan@outstand.com>
8
+ FROM ruby:2.7.1-alpine
9
+ LABEL maintainer="Ryan Schlesinger <ryan@outstand.com>"
10
10
 
11
11
  RUN addgroup -S shipitron && \
12
12
  adduser -S -G shipitron shipitron && \
13
13
  addgroup -g 1101 docker && \
14
14
  addgroup shipitron docker
15
15
 
16
- ENV GOSU_VERSION 1.10
17
- ENV DUMB_INIT_VERSION 1.2.0
18
-
19
16
  RUN apk add --no-cache \
20
17
  ca-certificates \
21
- openssl \
18
+ openssl-dev \
22
19
  tini \
23
20
  su-exec \
24
21
  build-base \
25
22
  git \
23
+ git-lfs \
26
24
  openssh-client \
27
25
  perl \
28
26
  bash \
29
27
  curl \
30
28
  wget \
31
- jq
29
+ jq \
30
+ cmake
31
+
32
+ ENV ECR_CREDENTIAL_HELPER_VERSION 0.4.0
33
+ RUN cd /usr/local/bin && \
34
+ wget https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${ECR_CREDENTIAL_HELPER_VERSION}/linux-amd64/docker-credential-ecr-login && \
35
+ chmod +x docker-credential-ecr-login
36
+
37
+ ENV BUILDKIT_VERSION v0.7.2
38
+ RUN cd /usr/local/bin && \
39
+ wget -nv https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz && \
40
+ tar --strip-components=1 -zxvf buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz bin/buildctl && \
41
+ chmod +x buildctl && \
42
+ rm -f buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz
43
+
44
+ USER shipitron
45
+ ENV BUILDX_VERSION v0.4.2
46
+ RUN cd /home/shipitron && \
47
+ wget -nv https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64 && \
48
+ mkdir -p ~/.docker/cli-plugins && \
49
+ mv buildx-${BUILDX_VERSION}.linux-amd64 ~/.docker/cli-plugins/docker-buildx && \
50
+ chmod a+x ~/.docker/cli-plugins/docker-buildx
32
51
 
52
+ USER root
33
53
  ENV USE_BUNDLE_EXEC true
34
54
  ENV BUNDLE_GEMFILE /shipitron/Gemfile
35
55
 
@@ -1,5 +1,5 @@
1
- FROM ruby:2.5.0-alpine3.7
2
- MAINTAINER Ryan Schlesinger <ryan@outstand.com>
1
+ FROM ruby:2.7.1-alpine
2
+ LABEL maintainer="Ryan Schlesinger <ryan@outstand.com>"
3
3
 
4
4
  RUN addgroup -S shipitron && \
5
5
  adduser -S -G shipitron shipitron && \
@@ -20,9 +20,31 @@ RUN apk add --no-cache \
20
20
  wget \
21
21
  jq
22
22
 
23
+ ENV ECR_CREDENTIAL_HELPER_VERSION 0.4.0
24
+ RUN cd /usr/local/bin && \
25
+ wget https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${ECR_CREDENTIAL_HELPER_VERSION}/linux-amd64/docker-credential-ecr-login && \
26
+ chmod +x docker-credential-ecr-login
27
+
28
+ ENV BUILDKIT_VERSION v0.7.2
29
+ RUN cd /usr/local/bin && \
30
+ wget -nv https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz && \
31
+ tar --strip-components=1 -zxvf buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz bin/buildctl && \
32
+ chmod +x buildctl && \
33
+ rm -f buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz
34
+
35
+ USER shipitron
36
+ ENV BUILDX_VERSION v0.4.2
37
+ RUN cd /home/shipitron && \
38
+ wget -nv https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64 && \
39
+ mkdir -p ~/.docker/cli-plugins && \
40
+ mv buildx-${BUILDX_VERSION}.linux-amd64 ~/.docker/cli-plugins/docker-buildx && \
41
+ chmod a+x ~/.docker/cli-plugins/docker-buildx
42
+
43
+ USER root
44
+
23
45
  WORKDIR /app
24
46
 
25
- ENV SHIPITRON_VERSION=1.0.1
47
+ ENV SHIPITRON_VERSION=1.3.1
26
48
 
27
49
  RUN gem install shipitron -v ${SHIPITRON_VERSION} && \
28
50
  mkdir -p /home/shipitron/.ssh && \
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+ gem 'irb'
data/README.md CHANGED
@@ -9,6 +9,7 @@ applications:
9
9
  dummy-app:
10
10
  repository: git@github.com:outstand/dummy-app
11
11
  cache_bucket: bucket
12
+ build_cache_location: tmp/build-cache.tar.gz
12
13
  image_name: outstand/dummy-app
13
14
  build_script: shipitron/build.sh
14
15
  post_builds:
@@ -30,25 +31,63 @@ applications:
30
31
  - Add deploy ref key to `shipitron/<app name>/deploy_ref_key`
31
32
  - `docker run -it --rm -v shipitron.yml:/shipitron/config/shipitron.yml outstand/shipitron:<version> deploy <app>`
32
33
 
34
+ ### New shipitron config file keys:
35
+
36
+ - registry (specifies an alternate docker registry):
37
+ ```yaml
38
+ ---
39
+ applications:
40
+ foobar:
41
+ registry: 12345.dkr.ecr.us-east-1.amazonaws.com
42
+ ```
43
+
44
+ - skip_push (shipitron will skip pushing the docker images; use if the build script takes care of this):
45
+ ```yaml
46
+ ---
47
+ applications:
48
+ foobar:
49
+ skip_push: true
50
+ ```
51
+ Additionally, the build script will receive the named tag in use as `$2`.
52
+
53
+ ### Containerized tool support
54
+ Shipitron now supports starting other containers as part of the build process. We're using this to use the aws cli to transfer files to/from s3. Shipitron's task definition needs to have a task scoped docker volume added with the name `shipitron-home`. This volume will be mounted at `/home/shipitron` and should be shared with any new containers:
55
+
56
+ ```
57
+ shipitron_home_volume = FindDockerVolumeName.call!(
58
+ container_name: 'shipitron',
59
+ volume_search: /shipitron-home/
60
+ ).volume_name
61
+
62
+ docker run ... -v #{shipitron_home_volume}:/home/shipitron ...
63
+ ```
64
+
65
+ This allows the containers to share data with each other. ECS will automatically clean up the task scoped container.
66
+
67
+ If a containerized tool requires access to AWS resources, be sure to pass the `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` to it so it can inherit any task roles.
68
+
33
69
  ## Development
34
70
 
35
- - `docker volume create --name shipitron_fog`
36
71
  - `./build_dev.sh`
37
- - `docker run -it --rm -v $(pwd):/shipitron -v shipitron_fog:/fog -e FOG_LOCAL=true -w /shipitron outstand/shipitron:dev rspec spec` to run specs
38
- - `APP_PATH=/path/to/app`
39
- - `docker run -it --rm -v $(pwd):/shipitron -v $HOME/.config/shipitron:/home/shipitron/.config/shipitron -v $APP_PATH:/app outstand/shipitron:dev deploy <app>` to run client side
40
- - `docker run -it --rm -v $(pwd):/shipitron -v $HOME/.config/shipitron:/home/shipitron/.config/shipitron -v $APP_PATH:/app outstand/shipitron:dev deploy <app> --simulate` to get the arguments for `server_deploy` below
41
- - `docker run -it --rm --dns 10.10.10.2 -v $(pwd):/shipitron -v $APP_PATH:/app -v /bin/docker:/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v shipitron_fog:/fog -e FOG_LOCAL=true -e CONSUL_HOST=consul outstand/shipitron:dev server_deploy --name dummy-app --repository git@github.com:outstand/dummy-app --bucket outstand-shipitron --image-name outstand/dummy-app --region us-east-1 --cluster-name us-east-1-prod-blue --ecs-task-defs dummy-app --ecs-services dummy-app --build-script shipitron/build.sh --post-builds 'ecs_task:dummy-app,container_name:dummy-app,command:echo postbuild' --ecs-task-def-templates LS0tCmZhbWlseTogZHVtbXktYXBwCmNvbnRhaW5lcl9kZWZpbml0aW9uczoKICAtIG5hbWU6IGR1bW15LWFwcAogICAgaW1hZ2U6IG91dHN0YW5kL2R1bW15LWFwcDp7e3RhZ319CiAgICBtZW1vcnk6IDEyOAogICAgZXNzZW50aWFsOiB0cnVlCiAgICBwb3J0X21hcHBpbmdzOgogICAgICAtIGNvbnRhaW5lcl9wb3J0OiA4MAogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gbmFtZTogU0VSVklDRV84MF9OQU1FCiAgICAgICAgdmFsdWU6IGR1bW15Cg== --ecs-service-templates LS0tCmNsdXN0ZXI6IHt7Y2x1c3Rlcn19CnNlcnZpY2VfbmFtZTogZHVtbXktYXBwCnRhc2tfZGVmaW5pdGlvbjogZHVtbXktYXBwe3tyZXZpc2lvbn19CmRlc2lyZWRfY291bnQ6IHt7Y291bnR9fQojcm9sZToge3tyb2xlfX0KZGVwbG95bWVudF9jb25maWd1cmF0aW9uOgogIG1heGltdW1fcGVyY2VudDogMjAwCiAgbWluaW11bV9oZWFsdGh5X3BlcmNlbnQ6IDUwCg== --debug` to run server side (dummy-app is an example)
72
+ - `dev run --rm shipitron_specs` to run specs
73
+ - Set the application path in the volumes section in `docker-compose.yml`.
74
+ - `dev run --rm shipitron deploy <app>` to run client side
75
+ - `dev run --rm shipitron deploy <app> --simulate` to get the arguments for `server_deploy` below
76
+ - `dev run --rm -v /bin/docker:/bin/docker -v /var/run/docker.sock:/var/run/docker.sock shipitron server_deploy --name dummy-app --repository git@github.com:outstand/dummy-app --bucket outstand-shipitron --image-name outstand/dummy-app --region us-east-1 --cluster-name us-east-1-prod-blue --ecs-task-defs dummy-app --ecs-services dummy-app --build-script shipitron/build.sh --post-builds 'ecs_task:dummy-app,container_name:dummy-app,command:echo postbuild' --ecs-task-def-templates LS0tCmZhbWlseTogZHVtbXktYXBwCmNvbnRhaW5lcl9kZWZpbml0aW9uczoKICAtIG5hbWU6IGR1bW15LWFwcAogICAgaW1hZ2U6IG91dHN0YW5kL2R1bW15LWFwcDp7e3RhZ319CiAgICBtZW1vcnk6IDEyOAogICAgZXNzZW50aWFsOiB0cnVlCiAgICBwb3J0X21hcHBpbmdzOgogICAgICAtIGNvbnRhaW5lcl9wb3J0OiA4MAogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gbmFtZTogU0VSVklDRV84MF9OQU1FCiAgICAgICAgdmFsdWU6IGR1bW15Cg== --ecs-service-templates LS0tCmNsdXN0ZXI6IHt7Y2x1c3Rlcn19CnNlcnZpY2VfbmFtZTogZHVtbXktYXBwCnRhc2tfZGVmaW5pdGlvbjogZHVtbXktYXBwe3tyZXZpc2lvbn19CmRlc2lyZWRfY291bnQ6IHt7Y291bnR9fQojcm9sZToge3tyb2xlfX0KZGVwbG95bWVudF9jb25maWd1cmF0aW9uOgogIG1heGltdW1fcGVyY2VudDogMjAwCiAgbWluaW11bV9oZWFsdGh5X3BlcmNlbnQ6IDUwCg== --debug` to run server side (dummy-app is an example)
42
77
 
43
78
  Running a dev version in production:
79
+ - Update `Shipitron::Client::STARTED_BY`
44
80
  - `docker push outstand/shipitron:dev`
45
81
  - Update config to use `shipitron_task: shipitron-dev`
46
- - `docker run -it --rm -v $(pwd):/shipitron -v $HOME/.config/shipitron:/home/shipitron/.config/shipitron -v $APP_PATH:/app outstand/shipitron:dev deploy <app> --debug`
82
+ - `dev run --rm shipitron deploy <app> --debug`
47
83
 
48
84
  To release a new version:
49
85
  - Update the version number in `version.rb` and `Dockerfile.release` and commit the result.
50
86
  - `./build_dev.sh`
51
87
  - `docker run -it --rm -v ~/.gitconfig:/root/.gitconfig -v ~/.gitconfig.user:/root/.gitconfig.user -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.gem:/root/.gem -w /shipitron outstand/shipitron:dev rake release`
52
- - `docker build -t outstand/shipitron:VERSION -f Dockerfile.release .`
53
- - `docker push outstand/shipitron:VERSION`
88
+ - `VERSION=<version>`
89
+ - `docker build -t outstand/shipitron:$VERSION -f Dockerfile.release .`
90
+ - `docker push outstand/shipitron:$VERSION`
91
+ - `docker tag outstand/shipitron:$VERSION outstand/shipitron:latest`
92
+ - `docker push outstand/shipitron:latest`
54
93
  - Update ECS task definition with new version
@@ -20,7 +20,7 @@ trap cleanup EXIT
20
20
  build_args=''
21
21
  mkdir -p ${bundler_data_dir}
22
22
 
23
- docker build -t ${build_image} -f ${dockerfile} ${build_args} .
23
+ docker build --pull -t ${build_image} -f ${dockerfile} ${build_args} .
24
24
 
25
25
  docker run -t --cidfile=${bundler_data_dir}/cidfile -w /usr/local/bundle ${build_image} tar -zcf /tmp/bundler-data.tar.gz .
26
26
  tar_container=$(cat ${bundler_data_dir}/cidfile)
@@ -0,0 +1,24 @@
1
+ version: '3.8'
2
+ services:
3
+ shipitron:
4
+ image: outstand/shipitron:dev
5
+ volumes:
6
+ - ~/dev/pages:/app # Set this to the application to be shipitron'd
7
+ - shipitron-home:/home/shipitron
8
+ - ~/.config/shipitron:/home/shipitron/.config/shipitron
9
+ - .:/shipitron
10
+ shipitron_specs:
11
+ image: outstand/shipitron:dev
12
+ command: rspec spec
13
+ environment:
14
+ FOG_LOCAL: 'true'
15
+ working_dir: /shipitron
16
+ volumes:
17
+ - fog:/fog
18
+ - shipitron-home:/home/shipitron
19
+ - ~/.config/shipitron:/home/shipitron/.config/shipitron
20
+ - .:/shipitron
21
+
22
+ volumes:
23
+ fog:
24
+ shipitron-home:
@@ -27,20 +27,47 @@ module Shipitron
27
27
  )
28
28
 
29
29
  if result.failure?
30
- result.errors.each do |error|
30
+ result.error_messages.each do |error|
31
31
  Logger.fatal error
32
32
  end
33
33
  Logger.fatal 'Deploy failed.'
34
34
  end
35
35
  end
36
36
 
37
+ desc 'force_deploy <app>', 'Forces a redeploy of the app'
38
+ option :config_file, default: 'shipitron/config.yml'
39
+ option :secrets_file, default: '~/.config/shipitron/secrets.yml'
40
+ option :debug, type: :boolean, default: false
41
+ def force_deploy(app)
42
+ setup(
43
+ config_file: options[:config_file],
44
+ secrets_file: options[:secrets_file]
45
+ )
46
+
47
+ require 'shipitron/client/force_deploy'
48
+ result = Client::ForceDeploy.call(
49
+ application: app
50
+ )
51
+
52
+ if result.failure?
53
+ result.error_messages.each do |error|
54
+ Logger.fatal error
55
+ end
56
+ Logger.fatal 'Deploy failed.'
57
+ end
58
+ end
59
+
60
+
37
61
  desc 'server_deploy', 'Server-side component of deploy'
38
62
  option :name, required: true
39
63
  option :repository, required: true
40
64
  option :repository_branch, default: 'master'
65
+ option :registry, default: nil
41
66
  option :bucket, required: true
67
+ option :build_cache_location, default: 'tmp/build-cache.tar.gz'
42
68
  option :image_name, required: true
43
69
  option :named_tag, default: 'latest'
70
+ option :skip_push, type: :boolean, default: false
44
71
  option :region, required: true
45
72
  option :clusters, type: :array, required: true
46
73
  option :ecs_task_defs, type: :array, required: true
@@ -61,9 +88,12 @@ module Shipitron
61
88
  application: options[:name],
62
89
  repository_url: options[:repository],
63
90
  repository_branch: options[:repository_branch],
91
+ registry: options[:registry],
64
92
  s3_cache_bucket: options[:bucket],
93
+ build_cache_location: options[:build_cache_location],
65
94
  image_name: options[:image_name],
66
95
  named_tag: options[:named_tag],
96
+ skip_push: options[:skip_push],
67
97
  region: options[:region],
68
98
  clusters: options[:clusters],
69
99
  ecs_task_defs: options[:ecs_task_defs],
@@ -80,7 +110,7 @@ module Shipitron
80
110
  )
81
111
 
82
112
  if result.failure?
83
- result.errors.each do |error|
113
+ result.error_messages.each do |error|
84
114
  Logger.fatal error
85
115
  end
86
116
  Logger.fatal 'Deploy failed.'
@@ -111,7 +141,7 @@ module Shipitron
111
141
  )
112
142
 
113
143
  if result.failure?
114
- result.errors.each do |error|
144
+ result.error_messages.each do |error|
115
145
  Logger.fatal error
116
146
  end
117
147
  Logger.fatal 'Bootstrap failed.'
@@ -0,0 +1,9 @@
1
+ require 'shipitron'
2
+
3
+ module Shipitron
4
+ module Client
5
+ STARTED_BY = 'shipitron'
6
+ # Use this for testing.
7
+ # STARTED_BY = 'shipitron-dev'
8
+ end
9
+ end
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'shipitron/client/register_ecs_task_definitions'
3
4
  require 'shipitron/client/create_ecs_services'
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'shipitron/ecs_client'
3
4
  require 'shipitron/mustache_yaml_parser'
4
5
  require 'securerandom'
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'shipitron/client/load_application_config'
3
4
  require 'shipitron/client/load_templates'
4
5
  require 'shipitron/client/fetch_clusters'
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'shipitron/ecs_client'
3
4
 
4
5
  # Note: This is a best effort client side check to make sure there
@@ -21,7 +22,7 @@ module Shipitron
21
22
  begin
22
23
  response = ecs_client(region: cluster.region).list_tasks(
23
24
  cluster: cluster.name,
24
- started_by: 'shipitron',
25
+ started_by: Shipitron::Client::STARTED_BY,
25
26
  max_results: 1,
26
27
  desired_status: status
27
28
  )
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'resolv'
3
4
 
4
5
  module Shipitron
@@ -0,0 +1,58 @@
1
+ require 'shipitron'
2
+ require 'shipitron/client'
3
+ require 'shipitron/ecs_client'
4
+ require 'shipitron/client/load_application_config'
5
+ require 'shipitron/client/fetch_clusters'
6
+ require 'shipitron/client/ensure_deploy_not_running'
7
+
8
+ module Shipitron
9
+ module Client
10
+ class ForceDeploy
11
+ include Metaractor
12
+ include Interactor::Organizer
13
+ include EcsClient
14
+
15
+ required :application
16
+
17
+ organize [
18
+ LoadApplicationConfig,
19
+ FetchClusters,
20
+ EnsureDeployNotRunning
21
+ ]
22
+
23
+ def call
24
+ Logger.info "==> Force deploying #{application}"
25
+
26
+ super
27
+
28
+ context.clusters ||= []
29
+ context.ecs_services ||= []
30
+
31
+ begin
32
+ context.clusters.each do |cluster|
33
+ context.ecs_services.each do |service|
34
+ ecs_client(region: cluster.region).update_service(
35
+ cluster: cluster.name,
36
+ service: service,
37
+ force_new_deployment: true
38
+ )
39
+ end
40
+ end
41
+ rescue Aws::ECS::Errors::ServiceError => e
42
+ fail_with_errors!(messages: [
43
+ "Error: #{e.message}",
44
+ e.backtrace.join("\n")
45
+ ])
46
+ end
47
+
48
+ Logger.info "==> Done"
49
+ end
50
+
51
+ private
52
+ def application
53
+ context.application
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -1,4 +1,5 @@
1
1
  require 'shipitron'
2
+ require 'shipitron/client'
2
3
  require 'shipitron/post_build'
3
4
 
4
5
  module Shipitron
@@ -11,7 +12,9 @@ module Shipitron
11
12
  def call
12
13
  context.repository_url = config.repository
13
14
  context.repository_branch = config.repository_branch
15
+ context.registry = config.registry
14
16
  context.s3_cache_bucket = config.cache_bucket
17
+ context.build_cache_location = config.build_cache_location
15
18
  context.image_name = config.image_name
16
19
  context.named_tag = begin
17
20
  if config.named_tag.nil?
@@ -20,6 +23,7 @@ module Shipitron
20
23
  config.named_tag
21
24
  end
22
25
  end
26
+ context.skip_push = config.skip_push
23
27
  context.build_script = config.build_script
24
28
  context.post_builds = begin
25
29
  if config.post_builds.nil?