Initial commit

This commit is contained in:
Danny Bessems 2020-12-30 11:58:00 +01:00
parent 676c6a8945
commit 18c2cc39e8
3 changed files with 166 additions and 0 deletions

36
.drone.yml Normal file
View File

@ -0,0 +1,36 @@
kind: pipeline
type: kubernetes
name: Harbor
steps:
- name: build & publish
image: plugins/docker
context: .
settings:
repo: bv11-cr01.bessems.eu/library/packer-extended
registry: bv11-cr01.bessems.eu
tags: latest
mtu: 1450
username:
from_secret: harbor_username
password:
from_secret: harbor_password
---
kind: pipeline
type: kubernetes
name: Dockerhub
steps:
- name: build & publish
image: plugins/docker
context: .
settings:
repo: djpbessems/packer-extended
tags: latest
mtu: 1450
username:
from_secret: docker_username
password:
from_secret: docker_password

66
Dockerfile Normal file
View File

@ -0,0 +1,66 @@
FROM hashicorp/packer:light as packer
# Error in 1.6.2 regarding packer_cache - see https://git.io/JUCwk
# FROM hashicorp/packer:1.6.1 as packer
FROM hashicorp/terraform:light as terraform
FROM alpine:latest AS download
ENV OVFTOOL_VERSION=4.4.1-16812187
ENV OVFTOOL_INSTALLER=VMware-ovftool-${OVFTOOL_VERSION}-lin.x86_64.bundle
ENV OVFTOOL_SHA256=ecdb3dcb58494d643d35661dcda948025661ec12ce615f043e1ec5d4c85de2ce
ARG RT_USERNAME
ARG RT_PASSWORD
ADD https://${RT_USERNAME}:${RT_PASSWORD}@devstore.vanderlande.com:443/artifactory/nlveg-mvn-release-local-01/com/vanderlande/itproj/3rd_party/applications/vmware/ovftool/${OVFTOOL_INSTALLER} /tmp/ovftool-installer
RUN apk --update add --no-cache \
curl \
jq && \
curl -L https://api.github.com/repos/rgl/packer-provisioner-windows-update/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url' | \
xargs -I {} curl -L -o /tmp/packer-provisioner-windows-update.tar.gz {} && \
tar -xzf /tmp/packer-provisioner-windows-update.tar.gz -C /tmp && \
chmod +x /tmp/packer-provisioner-windows-update && \
curl -L https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -o /tmp/packages-microsoft-prod.deb
FROM ruby:slim
COPY --from=packer /bin/packer /bin/packer
COPY --from=terraform /bin/terraform /bin/terraform
COPY --from=download /tmp/packer-provisioner-windows-update /bin/packer-provisioner-windows-update
COPY --from=download /tmp/packages-microsoft-prod.deb /tmp/packages-microsoft-prod.deb
COPY --from=download /tmp/ovftool-installer /tmp/ovftool-installer
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN dpkg -i /tmp/packages-microsoft-prod.deb && \
rm -f /tmp/packages-microsoft-prod.deb && \
apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
ansible \
build-essential \
git \
# icu-libs \
jq \
libxml2-dev \
libffi-dev \
locales \
netcat-openbsd \
openssh-client \
powershell \
unzip && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen && \
gem install inspec && \
gem install inspec-bin && \
apt-get remove -y \
build-essential && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
pwsh -Command "Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted' -Verbose" && \
pwsh -Command "Install-Module -Name 'VMware.PowerCLI' -Verbose" && \
sh /tmp/ovftool-installer --console --eulas-agreed --required && \
rm -f /tmp/ovftool-installer
ENTRYPOINT []
CMD []

64
Dockerfile.alpine Normal file
View File

@ -0,0 +1,64 @@
# Error in 1.6.2 regarding packer_cache - see https://git.io/JUCwk
#FROM hashicorp/packer:light as packer
FROM hashicorp/packer:1.6.1 as packer
FROM hashicorp/terraform:light as terraform
FROM alpine:latest AS download
RUN apk --update add --no-cache \
curl \
jq && \
curl -L https://api.github.com/repos/powershell/powershell/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux-alpine-x64"))| .browser_download_url' | \
xargs -I {} curl -L -o /tmp/powershell.tar.gz {} && \
mkdir -p /opt/microsoft/powershell/7 && \
tar -xzf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7 && \
chmod +x /opt/microsoft/powershell/7/pwsh && \
curl -L https://api.github.com/repos/rgl/packer-provisioner-windows-update/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url' | \
xargs -I {} curl -L -o /tmp/packer-provisioner-windows-update.tar.gz {} && \
tar -xzf /tmp/packer-provisioner-windows-update.tar.gz -C /tmp && \
chmod +x /tmp/packer-provisioner-windows-update
FROM ubuntu:latest AS build
ENV OVFTOOL_VERSION=4.4.1-16812187
ENV OVFTOOL_INSTALLER=VMware-ovftool-${OVFTOOL_VERSION}-lin.x86_64.bundle
ENV OVFTOOL_SHA256=ecdb3dcb58494d643d35661dcda948025661ec12ce615f043e1ec5d4c85de2ce
ARG RT_USERNAME
ARG RT_PASSWORD
ADD https://${RT_USERNAME}:${RT_PASSWORD}@devstore.vanderlande.com:443/artifactory/nlveg-mvn-release-local-01/com/vanderlande/itproj/3rd_party/applications/vmware/ovftool/${OVFTOOL_INSTALLER} /tmp
RUN echo "${OVFTOOL_SHA256} /tmp/${OVFTOOL_INSTALLER}" | sha256sum -c - && \
sh /tmp/${OVFTOOL_INSTALLER} -p /tmp/ovftool --console --eulas-agreed --required
FROM ruby:alpine
COPY --from=packer /bin/packer /bin/packer
COPY --from=terraform /bin/terraform /bin/terraform
COPY --from=download /opt/microsoft/powershell /opt/microsoft/powershell
COPY --from=download /tmp/packer-provisioner-windows-update /bin/packer-provisioner-windows-update
COPY --from=build /tmp/ovftool/lib/vmware-ovftool /usr/lib/vmware-ovftool
RUN apk --update add --no-cache \
ansible \
build-base \
curl \
git \
icu-libs \
jq \
libxml2-dev \
# libxml2-utils \
libffi-dev \
netcat-openbsd \
openssh-client \
unzip && \
gem install inspec && \
gem install inspec-bin && \
apk del build-base && \
ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh && \
pwsh -Command "Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted' -Verbose" && \
pwsh -Command "Install-Module -Name 'VMware.PowerCLI' -Verbose"
ENTRYPOINT []
CMD []