Skip to content

Commit 23514cd

Browse files
authored
130 docker orphan containers not being removed run out of storage (#131)
* Initial commit * typo fix
1 parent fb85ed9 commit 23514cd

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ The following inputs can be used as `step.with` keys
222222
#### **Application Inputs**
223223
| Name | Type | Description |
224224
|------------------|---------|------------------------------------|
225+
| `docker_remove_orphans` | Boolean | Set to `true` to turn the `--remove-orphans` flag. Defaults to `false`. |
225226
| `docker_full_cleanup` | Boolean | Set to `true` to run `docker-compose down` and `docker system prune --all --force --volumes` after. Runs before `docker_install`. WARNING: docker volumes will be destroyed. |
226227
| `app_directory` | String | Relative path for the directory of the app. (i.e. where the `docker-compose.yaml` file is located). This is the directory that is copied into the EC2 instance. Default is `/`, the root of the repository. Add a `.gha-ignore` file with a list of files to be exluded. (Using glob patterns). |
227228
| `app_directory_cleanup` | Boolean | Will generate a timestamped compressed file (in the home directory of the instance) and delete the app repo directory. Runs before `docker_install` and after `docker_full_cleanup`. |

action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ inputs:
5454
default: ''
5555

5656
# Application
57+
docker_remove_orphans:
58+
description: 'Toggle --remove-orphans flag. Defaults to false.'
59+
required: false
5760
docker_full_cleanup:
5861
description: 'Set to true to run docker-compose down and docker system prune --all --force --volumes after.'
5962
required: false
@@ -231,6 +234,7 @@ runs:
231234
CREATE_SUB_CERT: ${{ inputs.create_sub_cert }}
232235
NO_CERT: ${{ inputs.no_cert }}
233236
BITOPS_FAST_FAIL: true
237+
DOCKER_REMOVE_ORPHANS: ${{ inputs.docker_remove_orphans }}
234238
DOCKER_FULL_CLEANUP: ${{ inputs.docker_full_cleanup }}
235239
APP_DIRECTORY: ${{ inputs.app_directory }}
236240
APP_DIRECTORY_CLEANUP: ${{ inputs.app_directory_cleanup }}

operations/_scripts/generate/generate_tf_vars.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ application_mount_target=$(generate_var application_mount_target $APPLICATION_MO
158158
efs_mount_target=$(generate_var efs_mount_target $EFS_MOUNT_TARGET)
159159
data_mount_target=$(generate_var data_mount_target $DATA_MOUNT_TARGET)
160160
ec2_volume_size=$(generate_var ec2_volume_size $EC2_VOLUME_SIZE)
161+
docker_remove_orphans=$(generate_var docker_remove_orphans $DOCKER_REMOVE_ORPHANS)
161162

162163

163164
# -------------------------------------------------- #
@@ -236,5 +237,6 @@ $additional_tags
236237
$application_mount_target
237238
$efs_mount_target
238239
$data_mount_target
240+
$docker_remove_orphans
239241
240242
" > "${GITHUB_ACTION_PATH}/operations/deployment/terraform/terraform.tfvars"

operations/deployment/ansible/tasks/start.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
build: yes
66
recreate: always
77
nocache: yes
8+
remove_orphans: "{{ docker_remove_orphans }}"
9+
810
register: output
911

1012
- ansible.builtin.debug:

operations/deployment/terraform/inventory.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ bitops_servers:
1212
application_mount_target: ${application_mount_target}
1313
efs_mount_target: ${efs_mount_target}
1414
data_mount_target: ${data_mount_target}
15+
docker_remove_orphans: ${var.docker_remove_orphans}
16+

operations/deployment/terraform/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ variable "aws_replication_configuration_destination" {
256256
description = "AWS Region to target for replication"
257257
}
258258

259+
variable "docker_remove_orphans" {
260+
type = bool
261+
description = "ddefine if ansible should clean orphans"
262+
default = false
263+
}
264+
259265
## -- --- -- ##
260266
variable "availability_zone" {
261267
type = string

0 commit comments

Comments
 (0)