Skip to content

Commit

Permalink
refactor: update devcontainer (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthirtyam committed Sep 26, 2024
1 parent 2467d6b commit fa689ca
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
64 changes: 59 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,66 @@
# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2

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

# Install additional packages unavailable in the base image or as a feature.
# Note: Unable to be installed used the "postCreateCommand" option.
# Install additional packages.
RUN apt-get update && \
apt-get install -y jq xorriso whois && \
apt-get autoremove -y && \
apt-get install -y apt-transport-https curl git jq software-properties-common unzip wget whois xorriso ca-certificates

RUN update-ca-certificates

# Install Packer using the latest release.
RUN PACKER_VERSION=$(curl -s https://api.github.com/repos/hashicorp/packer/releases/latest | jq -r .tag_name | sed 's/^v//') && \
echo "Latest Packer Version: ${PACKER_VERSION}." && \
PACKER_URL="https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip" && \
echo "Downloading Packer from ${PACKER_URL}..." && \
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; } && \
echo "Installing Packer ${PACKER_VERSION}..." && \
unzip -o packer_${PACKER_VERSION}_linux_amd64.zip || { echo "Failed to unzip the download."; exit 1; } && \
mv packer /usr/local/bin/ || { echo "Error: Failed to move binary."; exit 1; } && \
rm packer_${PACKER_VERSION}_linux_amd64.zip || { echo "Error: Failed to remove download."; exit 1; }

# Install Terraform using the latest release.
RUN TERRAFORM_VERSION=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | jq -r .tag_name | sed 's/^v//') && \
echo "Latest Terraform Version: ${TERRAFORM_VERSION}." && \
TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" && \
echo "Downloading Terraform from ${TERRAFORM_URL}..." && \
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; } && \
echo "Installing Terraform ${TERRAFORM_VERSION}..." && \
unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip || { echo "Error: Failed to unzip the download."; exit 1; } && \
mv terraform /usr/local/bin/ || { echo "Error: Failed to the move binary."; exit 1; } && \
rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip || { echo "Error: Failed to remove download."; exit 1; }

# Install Gomplate using the latest release.
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//') && \
echo "Latest Gomplate Version: ${GOMPLATE_VERSION}." && \
GOMPLATE_URL="https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64" && \
echo "Downloading Gomplate ${GOMPLATE_VERSION}..." && \
wget --no-check-certificate -q -O gomplate_linux-amd64 ${GOMPLATE_URL} || { echo "Error: Failed to download."; exit 1; } && \
echo "Installing Gomplate ${GOMPLATE_VERSION}..." && \
chmod +x gomplate_linux-amd64 && \
mv gomplate_linux-amd64 /usr/local/bin/gomplate || { echo "Error: Failed to move binary."; exit 1; }

# Install PowerShell using the latest release.
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//') && \
echo "Latest PowerShell Version: ${PWSH_VERSION}." && \
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) && \
echo "Downloading PowerShell ${PWSH_VERSION}..." && \
wget --no-check-certificate -q $PWSH_DEB_URL || { echo "Error: Failed to download."; exit 1; } && \
echo "Installing PowerShell ${PWSH_VERSION}..." && \
dpkg -i $(basename $PWSH_DEB_URL) || { echo "Error: Failed to install PowerShell."; exit 1; } && \
rm $(basename $PWSH_DEB_URL) || { echo "Error: Failed to remove download."; exit 1; }

# Install Python3 and Ansible.
RUN add-apt-repository --yes --update ppa:ansible/ansible && \
apt-get update && \
apt-get install -y python3 python3-pip ansible

# Cleanup.
RUN apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set PATH
ENV PATH="$HOME/.local/bin:$PATH"
8 changes: 1 addition & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers-contrib/features/ansible:2": {},
"ghcr.io/devcontainers-contrib/features/packer-asdf:2": {},
"ghcr.io/devcontainers-contrib/features/terraform-asdf:2": {},
"ghcr.io/gickis/devcontainer-features/gomplate:1": {}
},
"features": {},
"customizations": {
"vscode": {
"extensions": [
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
"editor.formatOnType": true,
"editor.trimAutoWhitespace": true,
"editor.wordWrap": "off"
},
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
}
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v0.21.0

> Release Date: Not Released
> Release Date: 2024-09-26
**Bug Fix**:

Expand Down

0 comments on commit fa689ca

Please sign in to comment.