Skip to content

Commit

Permalink
Start using debian as base image (#35)
Browse files Browse the repository at this point in the history
* Start using debian as base image

Thanks to this we can use pre-built image of AZ which speeds up
the docker build allot

Co-authored-by: Carl Andersson <carl.andersson@xenit.se>
  • Loading branch information
Edvin N and CalleB3 authored Nov 16, 2021
1 parent 24a9688 commit d266afc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 79 deletions.
34 changes: 13 additions & 21 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ COPY ./go-tf-prepare/main.go main.go
COPY ./go-tf-prepare/pkg/ pkg/
RUN GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o tf-prepare main.go

FROM alpine:3.12.1
FROM debian:11.1-slim

RUN mkdir -p /tmp/install /usr/src /work
WORKDIR /tmp/install
#Base
RUN apt-get update -y && \
apt-get install -y git curl openssl pip make unzip gpg wget && \
apt-get install -y ansible=2.10.7+merged+base+2.10.8+dfsg-1 && \
apt-get install -y packer=1.6.6+ds1-2+b3

# libc6-compat is needed to load local terraform providers
RUN apk update && \
apk add bash libc6-compat
RUN pip --no-cache-dir install -U pip

# Base should always be first
COPY install-scripts/base.sh /usr/src/install-scripts/base.sh
RUN /usr/src/install-scripts/base.sh
RUN mkdir -p /tmp/install /usr/src /work
WORKDIR /tmp/install

# Install Azure CLI
COPY install-scripts/azure-cli.sh /usr/src/install-scripts/azure-cli.sh
Expand All @@ -28,14 +28,6 @@ RUN /usr/src/install-scripts/azure-cli.sh --version="2.30.0"
COPY install-scripts/aws-cli.sh /usr/src/install-scripts/aws-cli.sh
RUN /usr/src/install-scripts/aws-cli.sh --version="2.1.10"

# Install Ansible
COPY install-scripts/ansible.sh /usr/src/install-scripts/ansible.sh
RUN /usr/src/install-scripts/ansible.sh --version="2.10.3"

# Install Packer
COPY install-scripts/packer.sh /usr/src/install-scripts/packer.sh
RUN /usr/src/install-scripts/packer.sh --version="1.6.5" --sha="a49f6408a50c220fe3f1a6192ea21134e2e8f31092c507614cd27ad4f913234b"

# Install tflint
COPY install-scripts/tflint.sh /usr/src/install-scripts/tflint.sh
RUN /usr/src/install-scripts/tflint.sh --version="v0.24.1" --sha="2dbe3b423f5d3e0bb458d51761c97d51a4fd6c3d7bd1efd87c4aa3dc5199e7b2"
Expand Down Expand Up @@ -82,13 +74,13 @@ RUN /usr/src/install-scripts/kubectl.sh --version="v1.19.0" --sha="79bb0d2f05487
COPY install-scripts/helm.sh /usr/src/install-scripts/helm.sh
RUN /usr/src/install-scripts/helm.sh --version="v3.4.1" --sha="538f85b4b73ac6160b30fd0ab4b510441aa3fa326593466e8bf7084a9c288420"

# Cleanup should always be last
COPY install-scripts/cleanup.sh /usr/src/install-scripts/cleanup.sh
RUN /usr/src/install-scripts/cleanup.sh

COPY --from=tf-prepare-builder /workspace/tf-prepare /usr/local/bin/tf-prepare
RUN chmod +x /usr/local/bin/tf-prepare

#Cleanup
RUN apt-get autoremove && \
apt-get clean

RUN rm -rf /tmp/install

COPY opa-policies /opt/opa-policies
Expand Down
16 changes: 0 additions & 16 deletions docker/install-scripts/ansible.sh

This file was deleted.

12 changes: 11 additions & 1 deletion docker/install-scripts/azure-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ while [ $# -gt 0 ]; do
shift
done

pip --no-cache-dir install azure-cli==${VERSION}
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
gpg --dearmor |
tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
tee /etc/apt/sources.list.d/azure-cli.list

apt-get update
apt-get install -y azure-cli=${VERSION}-1~$AZ_REPO

az extension add --name azure-devops
az extension add --name managementpartner
8 changes: 0 additions & 8 deletions docker/install-scripts/base.sh

This file was deleted.

4 changes: 0 additions & 4 deletions docker/install-scripts/cleanup.sh

This file was deleted.

29 changes: 0 additions & 29 deletions docker/install-scripts/packer.sh

This file was deleted.

0 comments on commit d266afc

Please sign in to comment.