Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Added Dockerfile with Bedrock prerequisites #1407

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ shunit2
vendor
flux
kubediff
locust
locust

secrets*
Binary file added bedrock-architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions cluster/azure/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from: https://youtu.be/H5uq60pb2Hs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove



# Azure Cluster Creation Guide

## Summary
Expand Down
20 changes: 20 additions & 0 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM debian:stretch
LABEL createdBy="https://twitter.com/carlesanagustin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove


RUN apt-get update && \
apt-get install -y unzip git

COPY ./prereqs/*.sh /

RUN /setup_azure_cli.sh && \
/setup_bedrock_cli.sh && \
/setup_fabrikate.sh && \
/setup_helm.sh && \
/setup_kubectl.sh && \
/setup_terraform.sh

RUN rm -f /*.sh && \
apt-get purge -y unzip && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/bin/bash"]
16 changes: 16 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DOCKERFILE ?= .
IMAGE_FROM ?= debian:stretch
IMAGE ?= bedrock:latest
MOUNT ?= $(shell pwd)

d_source:
docker run --rm -it -v $(MOUNT):/shared $(IMAGE_FROM) /bin/bash

d_build:
docker build -t $(IMAGE) $(DOCKERFILE)

d_run:
docker run --rm -it -v $(MOUNT):/shared $(IMAGE)

d_rmi:
docker rmi $(IMAGE)
19 changes: 18 additions & 1 deletion tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,21 @@ This directory contains tools for working with both the release process as well
Currently, the scripts are:

- `bedrock_terraform_release.sh` - this script updates remote references and creates a branch for which releases can be generated
- `toggle_remote_ref.sh` - this script is used to toggle remote references in your repository so when a PR is issued with changes affecting remote modules, those changes (in the branch the PR is based on) can be toggled easily for testing (and then returned to reference master post testing)
- `toggle_remote_ref.sh` - this script is used to toggle remote references in your repository so when a PR is issued with changes affecting remote modules, those changes (in the branch the PR is based on) can be toggled easily for testing (and then returned to reference master post testing)

## Dockerfile with Bedrock prerequisites

### Description

This Dockerfile creates a Debian image with all Bedrock prerequisites `prereqs/setup*.sh` installed ready to use from any Docker based system. It is composed of a `Dockerfile` with the image definition and a `Makefile` with all Docker CLI instructions.

### Requirements

* `make`: [https://www.gnu.org/software/make/](https://www.gnu.org/software/make/)
* `docker`: [https://docs.docker.com/](https://docs.docker.com/)

### Instructions

* Build docker image: `make d_build`
* Run docker container and get bash in it: `make d_run`
* Remember you can use this image to run any prerequisite command with `docker run [OPTIONS] bedrock:latest terraform [ARG...]`
16 changes: 9 additions & 7 deletions tools/prereqs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,41 @@ We maintain an individual script for each prerequisite to make this easier.

NOTE: You do not need to use these scripts if you are already utilizing a package manager like `apt` or `brew` to install these.

To use this, clone the bedrock repository locally and then navigate to `tools/prereqs` and execute the appropriate scripts for the prerequisites you need to install:
To use this, clone the bedrock repository locally and then navigate to `tools/prereqs` and execute the appropriate scripts for the prerequisites you need to install or create a Docker image with `tools/Dockerfile` provided.

## Azure CLI
## Install locally

### Azure CLI

```bash
$ sudo ./setup_azure_cli.sh
```

## kubectl
### kubectl

```bash
$ sudo ./setup_kubectl.sh
```

## Helm
### Helm

```bash
$ sudo ./setup_helm.sh
```

## Fabrikate
### Fabrikate

```bash
$ sudo ./setup_fabrikate.sh
```

## Terraform
### Terraform

```bash
$ sudo ./setup_terraform.sh
```

## Bedrock CLI
### Bedrock CLI

```bash
$ sudo ./setup_bedrock_cli.sh
Expand Down
13 changes: 7 additions & 6 deletions tools/prereqs/setup_azure_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ require_root
function apt_install() {
# prompt for confirmation
echo "This script will install the latest version of the Azure CLI using the Microsoft APT repo."
read -p "Do you wish to continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# next 6 lines commented due to automation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes to the shell scripts make it difficult to re-use as they previously were. I suggest adding an override instead of commenting out these blocks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting an environment variable in the Dockerfile like ASSUME_YES or NO_INPUT, maybe prefixed with BEDROCK_ could work?

#read -p "Do you wish to continue? " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# install base set of tools
apt-get update
Expand Down
13 changes: 7 additions & 6 deletions tools/prereqs/setup_bedrock_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ trap finish EXIT

# prompt for confirmation
echo "This script will install the latest version of Bedrock CLI from github."
read -p "Do you wish to continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# next 6 lines commented due to automation
#read -p "Do you wish to continue? " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# create a temporary directory to do work in
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
Expand Down
14 changes: 8 additions & 6 deletions tools/prereqs/setup_fabrikate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ trap finish EXIT
# prompt for confirmation
echo "This script will install the latest version of Fabrikate from github."
echo "The script requires that unzip be installed."
read -p "Do you wish to continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# next 6 lines commented due to automation
#read -p "Do you wish to continue? " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# determine os type
ostype=`os_type`
if [ "$ostype" == "linux" ]; then
arch="linux-amd64"
apt-get install -y unzip
elif [ "$ostype" == "macos" ]; then
arch="darwin-amd64"
else
Expand Down
13 changes: 7 additions & 6 deletions tools/prereqs/setup_helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ trap finish EXIT
# prompt for confirmation
echo "This script will install version $HELM_DESIRED_VERSION of helm from Github."
echo "Bedrock currently only supports version 2.x of helm."
read -p "Do you wish to continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# next 6 lines commented due to automation
#read -p "Do you wish to continue? " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# create a temporary directory to do work in
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
Expand Down
13 changes: 7 additions & 6 deletions tools/prereqs/setup_kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ trap finish EXIT

# prompt for confirmation
echo "This script will install the latest version of kubectl."
read -p "Do you wish to continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# next 6 lines commented due to automation
#read -p "Do you wish to continue? " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# create a temporary directory to do work in
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
Expand Down
16 changes: 9 additions & 7 deletions tools/prereqs/setup_terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ trap finish EXIT

# prompt for confirmation
echo "This script will install the latest version of Terraform from github."
read -p "Do you wish to continue? (y or n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo "The script requires that unzip be installed."
# next 6 lines commented due to automation
#read -p "Do you wish to continue? (y or n)" -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# exit 1
#fi

# create a temporary directory to do work in
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
Expand All @@ -30,7 +32,7 @@ cd $tmp_dir
ostype=`os_type`
if [ "$ostype" == "linux" ]; then
arch="linux_amd64"
sudo apt-get install unzip
apt-get install -y unzip
elif [ "$ostype" == "macos" ]; then
arch="darwin_amd64"
else
Expand Down