Skip to content

Commit e110b24

Browse files
committed
refactor: update devcontainer (#967)
1 parent 2467d6b commit e110b24

File tree

5 files changed

+65
-14
lines changed

5 files changed

+65
-14
lines changed

.devcontainer/Dockerfile

+59-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
11
# Copyright 2023-2024 Broadcom. All Rights Reserved.
22
# SPDX-License-Identifier: BSD-2
33

4-
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
4+
# Use the base Ubuntu devcontainer image.
5+
FROM mcr.microsoft.com/devcontainers/base:ubuntu
56

6-
# Install additional packages unavailable in the base image or as a feature.
7-
# Note: Unable to be installed used the "postCreateCommand" option.
7+
# Install additional packages.
88
RUN apt-get update && \
9-
apt-get install -y jq xorriso whois && \
10-
apt-get autoremove -y && \
9+
apt-get install -y apt-transport-https curl git jq software-properties-common unzip wget whois xorriso ca-certificates
10+
11+
RUN update-ca-certificates
12+
13+
# Install Packer using the latest release.
14+
RUN PACKER_VERSION=$(curl -s https://api.github.com/repos/hashicorp/packer/releases/latest | jq -r .tag_name | sed 's/^v//') && \
15+
echo "Latest Packer Version: ${PACKER_VERSION}." && \
16+
PACKER_URL="https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip" && \
17+
echo "Downloading Packer from ${PACKER_URL}..." && \
18+
wget --no-check-certificate -q -O packer_${PACKER_VERSION}_linux_amd64.zip ${PACKER_URL} || { echo "Error: Failed to download."; wget --no-check-certificate ${PACKER_URL}; exit 1; } && \
19+
echo "Installing Packer ${PACKER_VERSION}..." && \
20+
unzip -o packer_${PACKER_VERSION}_linux_amd64.zip || { echo "Failed to unzip the download."; exit 1; } && \
21+
mv packer /usr/local/bin/ || { echo "Error: Failed to move binary."; exit 1; } && \
22+
rm packer_${PACKER_VERSION}_linux_amd64.zip || { echo "Error: Failed to remove download."; exit 1; }
23+
24+
# Install Terraform using the latest release.
25+
RUN TERRAFORM_VERSION=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | jq -r .tag_name | sed 's/^v//') && \
26+
echo "Latest Terraform Version: ${TERRAFORM_VERSION}." && \
27+
TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" && \
28+
echo "Downloading Terraform from ${TERRAFORM_URL}..." && \
29+
wget --no-check-certificate -q -O terraform_${TERRAFORM_VERSION}_linux_amd64.zip ${TERRAFORM_URL} || { echo "Error: Failed to download."; wget --no-check-certificate ${TERRAFORM_URL}; exit 1; } && \
30+
echo "Installing Terraform ${TERRAFORM_VERSION}..." && \
31+
unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip || { echo "Error: Failed to unzip the download."; exit 1; } && \
32+
mv terraform /usr/local/bin/ || { echo "Error: Failed to the move binary."; exit 1; } && \
33+
rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip || { echo "Error: Failed to remove download."; exit 1; }
34+
35+
# Install Gomplate using the latest release.
36+
RUN GOMPLATE_VERSION=$(wget --no-check-certificate -q -O - https://api.github.com/repos/hairyhenderson/gomplate/releases/latest | jq -r .tag_name | sed 's/^v//') && \
37+
echo "Latest Gomplate Version: ${GOMPLATE_VERSION}." && \
38+
GOMPLATE_URL="https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64" && \
39+
echo "Downloading Gomplate ${GOMPLATE_VERSION}..." && \
40+
wget --no-check-certificate -q -O gomplate_linux-amd64 ${GOMPLATE_URL} || { echo "Error: Failed to download."; exit 1; } && \
41+
echo "Installing Gomplate ${GOMPLATE_VERSION}..." && \
42+
chmod +x gomplate_linux-amd64 && \
43+
mv gomplate_linux-amd64 /usr/local/bin/gomplate || { echo "Error: Failed to move binary."; exit 1; }
44+
45+
# Install PowerShell using the latest release.
46+
RUN PWSH_VERSION=$(wget --no-check-certificate -q -O - https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq -r .tag_name | sed 's/^v//') && \
47+
echo "Latest PowerShell Version: ${PWSH_VERSION}." && \
48+
PWSH_DEB_URL=$(wget --no-check-certificate -q -O - https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq -r '.assets[] | select(.name | endswith("amd64.deb")).browser_download_url' | head -n 1) && \
49+
echo "Downloading PowerShell ${PWSH_VERSION}..." && \
50+
wget --no-check-certificate -q $PWSH_DEB_URL || { echo "Error: Failed to download."; exit 1; } && \
51+
echo "Installing PowerShell ${PWSH_VERSION}..." && \
52+
dpkg -i $(basename $PWSH_DEB_URL) || { echo "Error: Failed to install PowerShell."; exit 1; } && \
53+
rm $(basename $PWSH_DEB_URL) || { echo "Error: Failed to remove download."; exit 1; }
54+
55+
# Install Python3 and Ansible.
56+
RUN add-apt-repository --yes --update ppa:ansible/ansible && \
57+
apt-get update && \
58+
apt-get install -y python3 python3-pip ansible
59+
60+
# Cleanup.
61+
RUN apt-get autoremove -y && \
1162
apt-get clean && \
1263
rm -rf /var/lib/apt/lists/*
64+
65+
# Set PATH
66+
ENV PATH="$HOME/.local/bin:$PATH"

.devcontainer/devcontainer.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
"build": {
44
"dockerfile": "Dockerfile"
55
},
6-
"features": {
7-
"ghcr.io/devcontainers/features/powershell:1": {},
8-
"ghcr.io/devcontainers-contrib/features/ansible:2": {},
9-
"ghcr.io/devcontainers-contrib/features/packer-asdf:2": {},
10-
"ghcr.io/devcontainers-contrib/features/terraform-asdf:2": {},
11-
"ghcr.io/gickis/devcontainer-features/gomplate:1": {}
12-
},
6+
"features": {},
137
"customizations": {
148
"vscode": {
159
"extensions": [

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@
5959
"editor.formatOnType": true,
6060
"editor.trimAutoWhitespace": true,
6161
"editor.wordWrap": "off"
62+
},
63+
"[dockerfile]": {
64+
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
6265
}
6366
}

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## v0.21.0
44

5-
> Release Date: Not Released
5+
> Release Date: 2024-09-26
66
77
**Bug Fix**:
88

project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"project": {
33
"name": "Packer Examples for vSphere",
4-
"version": "v0.21.0-dev",
4+
"version": "v0.21.0",
55
"description": "This project provides a collection of opinionated examples that demonstrate how you can use both\nHashiCorp Packer and the Packer Plugin for VMware vSphere (vsphere-iso builder) to automate the\ncreation of virtual machine images for VMware vSphere environments.\n\nWhether you're a developer, systems administrator, or site reliability engineer, this project is\ndesigned to both help and inspire you in streamlining your infrastructure provisioning process and\nmaintain consistency in your virtualization workflow.",
66
"urls": {
77
"github": "https://github.com/vmware-samples/packer-examples-for-vsphere",

0 commit comments

Comments
 (0)