From b48cce3759fbcf6a23da7df36fe53e395fa20232 Mon Sep 17 00:00:00 2001 From: James Hackett Date: Tue, 26 Dec 2023 20:33:58 +0000 Subject: [PATCH] #15: Reduce size of image by 600mb (#16) --- CHANGELOG.md | 4 ++++ Dockerfile | 11 +++++------ README.md | 11 +++++++++-- build-files/.bashrc | 1 + containsible | 26 ++++++++++++++++++-------- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 135717c..9043a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- #15: Reduce size of image + ## [0.5.0] - 2023-08-21 ### Added - #13: Add ansible.cfg file diff --git a/Dockerfile b/Dockerfile index fef4847..0c06b42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,21 @@ FROM debian:bookworm-slim AS base -RUN apt update -RUN apt install -y gnupg - WORKDIR /root COPY build-files build-files RUN cat build-files/.bashrc >> /root/.bashrc -RUN apt update && apt install -y curl \ +RUN apt update && apt install --no-install-recommends -y gnupg \ dnsutils \ net-tools \ - nmap \ python3 \ python-is-python3 \ python3-pip \ pipx \ - vim + vim \ + && apt autoremove -y \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* RUN pipx install --include-deps ansible diff --git a/README.md b/README.md index 9c7b876..e11b946 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,23 @@ # containsible -A standard environment for running ansible. +A standard environment for running ansible. Includes playbooks and roles, with customisable host files for a single entrypoint and repeatable environments to allow multiple people interact across various machines. +## Usage + +```bash +$ ./containsible run +``` + ## Installation Download the `bootstrap.sh` file + ```bash # curl ``` -#TODO: Add script here +#TODO: Add script here diff --git a/build-files/.bashrc b/build-files/.bashrc index 3fd795c..bcc39f5 100644 --- a/build-files/.bashrc +++ b/build-files/.bashrc @@ -1,3 +1,4 @@ eval "$(register-python-argcomplete pipx)" export PATH="/root/.local/bin:$PATH" +export EDITOR="vim" \ No newline at end of file diff --git a/containsible b/containsible index aef2e10..ff9f25c 100755 --- a/containsible +++ b/containsible @@ -2,15 +2,16 @@ set -e use_local_image=false +verbose=false # Run the containsible Docker container # Arguments: $1 - Environment name run_containsible() { local environment="$1" - if $use_local_image; then + if [ "$use_local_image" = true ]; then echo "Skipping version check for local image." - docker run -it --hostname "$environment" containsible + docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible:latest else docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible:latest fi @@ -38,7 +39,7 @@ update_container() { # Display error for invalid usage error_invalid_usage() { - echo "Usage: $(basename $0) run [--local|-l] " + echo "Usage: $(basename $0) run [--local|-l, --verbose|-v] " exit 1 } @@ -53,6 +54,10 @@ handle_run_subcommand() { use_local_image=true shift ;; + -v|--verbose) + verbose=true + shift + ;; *) break ;; @@ -73,9 +78,13 @@ handle_run_subcommand() { error_invalid_usage fi - if ! $use_local_image; then + if [ "$use_local_image" = false ]; then echo "Pulling the latest remote image..." - docker pull ghcr.io/distrobyte/containsible:latest >/dev/null 2>&1 + if [ "$verbose" = true ]; then + docker pull ghcr.io/distrobyte/containsible:latest + else + docker pull ghcr.io/distrobyte/containsible:latest >/dev/null 2>&1 + fi echo "Latest remote image pulled successfully." fi @@ -94,6 +103,10 @@ handle_update_subcommand() { use_local_image=true shift ;; + -v|--verbose) + verbose=true + shift + ;; *) break ;; @@ -124,9 +137,6 @@ main() { run) handle_run_subcommand "$@" ;; - prune) - prune_images - ;; update) handle_update_subcommand "$@" ;;