Skip to content

Commit

Permalink
#15: Reduce size of image by 600mb (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
DistroByte authored Dec 26, 2023
1 parent 1dd7d99 commit b48cce3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <environment>
```

## Installation

Download the `bootstrap.sh` file

```bash
# curl
```
#TODO: Add script here

#TODO: Add script here
1 change: 1 addition & 0 deletions build-files/.bashrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
eval "$(register-python-argcomplete pipx)"

export PATH="/root/.local/bin:$PATH"
export EDITOR="vim"
26 changes: 18 additions & 8 deletions containsible
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,7 +39,7 @@ update_container() {

# Display error for invalid usage
error_invalid_usage() {
echo "Usage: $(basename $0) run [--local|-l] <environment>"
echo "Usage: $(basename $0) run [--local|-l, --verbose|-v] <environment>"
exit 1
}

Expand All @@ -53,6 +54,10 @@ handle_run_subcommand() {
use_local_image=true
shift
;;
-v|--verbose)
verbose=true
shift
;;
*)
break
;;
Expand All @@ -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

Expand All @@ -94,6 +103,10 @@ handle_update_subcommand() {
use_local_image=true
shift
;;
-v|--verbose)
verbose=true
shift
;;
*)
break
;;
Expand Down Expand Up @@ -124,9 +137,6 @@ main() {
run)
handle_run_subcommand "$@"
;;
prune)
prune_images
;;
update)
handle_update_subcommand "$@"
;;
Expand Down

0 comments on commit b48cce3

Please sign in to comment.