Commit Graph

1122 Commits

Author SHA1 Message Date
Josh Soref
91fb85d6b5 spelling: etc.
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-05-29 20:46:34 -04:00
Donal McBreen
db0bf6bb16 Add a pre-deploy hook
Useful for checking the status of CI before deploying. Doing this at
this point in the deployment maximises the parallelisation of building
and running CI.
2023-05-29 16:06:41 +01:00
David Heinemeier Hansson
de2de19434 Merge pull request #315 from basecamp/prune-unused-images
Prune unused images correctly
2023-05-29 11:42:49 +02:00
David Heinemeier Hansson
f9fbebaa72 Merge pull request #316 from f440/fix-typo
Fix typo
2023-05-29 11:42:26 +02:00
Donal McBreen
1e300f3798 Wait longer for app to come up 2023-05-29 08:31:19 +01:00
f440
0373f6c4de Fix typo 2023-05-27 16:27:19 +09:00
Donal McBreen
9037088f99 Increase nginx timeouts in load balancer 2023-05-25 17:31:20 +01:00
Donal McBreen
ff7a1e6726 Prune unused images correctly
dangling=true doesn't prune any images, as we are not creating dangling
images.

Using --all should remove unused images, but it considers the Git SHA
tag on the latest image to be unused (presumably because there are two
tags, the SHA and latest and the running container is only considered to
be using "latest"). As a result it deletes the tag, which means that we
can't rollback to that SHA later.

Its a bit more complicated to only remove images that are not referenced
by any containers.

First we find the tags we want to keep from the containers (running and
stopped).

Then we append the latest tag to that list.

Then we get a full list of image tags and remove those tags from that
list (using `grep -v -w`).

Finally we pass the tags to `docker rmi`. That either deletes the tag if
there are other references to the image or both the tag and the image if
it is the only one.
2023-05-25 17:16:46 +01:00
David Heinemeier Hansson
602aa43496 Bump version for 0.13.1 v0.13.1 2023-05-25 14:04:29 +02:00
David Heinemeier Hansson
e35334e5fe Merge pull request #313 from basecamp/stop-restarting-containers
Stop containers with restarting status
2023-05-25 14:04:09 +02:00
Donal McBreen
cedb8d900f Stop containers with restarting status
When stopping the old container we need to also look for ones with a
restarting status.
2023-05-25 12:10:26 +01:00
David Heinemeier Hansson
8f0b7829ce Bump version for 0.13.0 v0.13.0 2023-05-25 12:05:04 +02:00
David Heinemeier Hansson
57e4f08c4c Merge pull request #308 from tannakartikey/hooks_small_fix
Hooks sample files typo fix
2023-05-25 09:02:25 +02:00
David Heinemeier Hansson
a8bfe90fbe Merge pull request #312 from shafy/docs_docker_setup
docs: change intro command to mrsk setup
2023-05-25 09:01:04 +02:00
David Heinemeier Hansson
f114dd71f6 Merge pull request #311 from basecamp/pre-connect-hook
Add a pre-connect hook
2023-05-25 08:58:19 +02:00
Can Olcer
d1b5b9cf7a docs: change intro command to mrsk setup 2023-05-24 20:32:41 +02:00
Donal McBreen
66f9ce0e90 Add a pre-connect hook
This can be used for hooks that should run before connecting to remote
hosts. An example use case is pre-warming DNS.
2023-05-24 14:39:30 +01:00
Kartikey Tanna
956ab3560b Hooks typo fix 2023-05-23 22:12:49 +05:30
David Heinemeier Hansson
483b893018 Merge pull request #291 from basecamp/hooks
MRSK Hooks
2023-05-23 17:07:04 +02:00
Donal McBreen
19f0f40adf Add skip_hooks option 2023-05-23 15:56:47 +01:00
Donal McBreen
f9cb87e55a Fixup rebase issues 2023-05-23 14:10:38 +01:00
Donal McBreen
cc2b321d93 Combine post-deploy and post-rollback 2023-05-23 13:57:24 +01:00
Donal McBreen
004f1b04e6 Remove the skip_broadcast option 2023-05-23 13:57:00 +01:00
Donal McBreen
3b695ae127 Add service_version and add running hook message 2023-05-23 13:56:19 +01:00
Donal McBreen
258887a451 Set sample hook permissions and preserve when copying 2023-05-23 13:56:19 +01:00
Donal McBreen
9fd184dc32 Add post-deploy and post-rollback hooks
These replace the custom audit_broadcast_cmd code. An additional env
variable MRSK_RUNTIME is passed to them.

The audit broadcast after booting an accessory has been removed.
2023-05-23 13:56:16 +01:00
Donal McBreen
38023fe538 Remove post push hook 2023-05-23 13:55:05 +01:00
Donal McBreen
0bc1fbfb74 Set max-concurrent-downloads to 1 to prevent timeouts 2023-05-23 13:55:05 +01:00
David Heinemeier Hansson
5ab630cb03 Style 2023-05-23 13:55:04 +01:00
Donal McBreen
910f14e9c0 Add configuration for hooks_path 2023-05-23 13:55:04 +01:00
Donal McBreen
f3ec9f19c8 Add debug for failed version checks 2023-05-23 13:55:04 +01:00
Donal McBreen
58c1096a90 MRSK hooks
Adds hooks to MRSK. Currently just two hooks, pre-build and post-push.

We could break the build and push into two separate commands if we
found the need for post-build and/or pre-push hooks.

Hooks are stored in `.mrsk/hooks`. Running `mrsk init` will now create
that folder and add sample hook scripts.

Hooks returning non-zero exit codes will abort the current command.

Further potential work here:
- We could replace the audit broadcast command with a
post-deploy/post-rollback hook or similar
- Maybe provide pre-command/post-command hooks that run after every
mrsk invocation
- Also look for hooks in `~/.mrsk/hooks`
2023-05-23 13:55:04 +01:00
Donal McBreen
340ed94fa9 Make verify_local_dependencies private
We don't need to what it returns, it raises if there is a problem.

Move it out of the run_locally block to make it easier to add hooks.
2023-05-23 13:55:04 +01:00
David Heinemeier Hansson
4e9c39f26d Merge pull request #271 from basecamp/app-boot-for-rollback
Call app:boot to rollback
2023-05-23 13:17:30 +02:00
David Heinemeier Hansson
d08aacadac Merge pull request #287 from Novtopro/traefik-inject-environment-variables
Allow to inject environment variables to traefik
2023-05-22 10:10:34 +02:00
David Heinemeier Hansson
702490d10f Merge pull request #305 from johnmcdowall/update_readme_for_aws_ecr
Update the README with info on AWS ECR
2023-05-22 09:58:33 +02:00
David Heinemeier Hansson
13079dd2a3 Merge pull request #299 from basecamp/report-host-with-error
Report the host an error occurred on
2023-05-22 09:57:22 +02:00
John McDowall
7daee9a0df Update the README on the use of shelling out to the aws cli command to obtain the token for ECR automatically 2023-05-20 13:46:05 -07:00
Donal McBreen
f7c5840473 Report the host an error occurred on
The cause message doesn't include the host the error occurred on.

Before:

```
$ mrsk deploy
Acquiring the deploy lock...
  Finished all in 0.1 seconds
  ERROR (SocketError): getaddrinfo: nodename nor servname provided, or not known
```

After:

```
$ mrsk deploy -d staging
Acquiring the deploy lock...
  Finished all in 0.1 seconds
  ERROR (SocketError): Exception while executing on host server-123: getaddrinfo: nodename nor servname provided, or not known
```
2023-05-17 08:51:01 +01:00
David Heinemeier Hansson
a7d869ad40 Merge pull request #298 from basecamp/more-integration-tests 2023-05-17 09:39:00 +02:00
Donal McBreen
7cd25fd163 Add more integration tests
Add tests for main, app, accessory, traefik and lock commands.
Other commands are generally covered by the main tests.

Also adds some changes to speed up the integration specs:
- Use a persistent volume for the registry so we can push images to to
reuse between runs (also gets around docker hub rate limits)
- Use persistent volume for mrsk gem install, to avoid re-installing
between tests
- Shorter stop wait time
- Shorter connection timeouts on the load balancer

Takes just over 2 minutes to run all tests locally on an M1 Mac
after docker caches are primed.
2023-05-16 10:35:35 +01:00
Donal McBreen
ee25f200d7 Call app:boot to rollback
The code in Mrsk::Cli::Main#rollback was very similar to
Mrsk::Cli::App#boot.

Modify Mrsk::Cli::App#boot so it can handle rollbacks by:
1. Only renaming running containers
2. Trying first to start then run the new container
2023-05-16 08:59:07 +01:00
David Heinemeier Hansson
059388cb02 Merge pull request #292 from basecamp/unique-uncommited-changes-version
Highlight uncommitted changes in version
2023-05-15 14:05:31 +02:00
Donal McBreen
a5ef1f254f Highlight uncommitted changes in version
If there are uncommitted changes in the app repository when building,
then append `_uncommitted_<random>` to it to distinguish the image
from one built from a clean checkout.

Also change the version used when renaming a container on redeploy to
distinguish and explain the version suffixes.
2023-05-12 11:08:48 +01:00
David Heinemeier Hansson
15e8ac0ced Merge pull request #290 from acidtib/check-interval
add healthcheck interval option
2023-05-11 14:13:13 +02:00
acidtib
9a31c20321 add healthcheck interval option 2023-05-10 20:27:21 -06:00
River He
44b83151e3 Allow to inject environment variables to traefik 2023-05-10 03:18:26 +00:00
David Heinemeier Hansson
0defcbb640 Merge pull request #283 from basecamp/better-lock-messages
Better lock messages
2023-05-09 16:06:50 +02:00
Donal McBreen
5d33fb6c33 Better lock messages
- Debug verbosity commands
- Show lock status when we fail to acquire it
- Include lock acquire/release in runtime
2023-05-09 14:17:58 +01:00
David Heinemeier Hansson
e9d838ec46 Update README.md 2023-05-09 14:32:02 +02:00