Skip to content

Commit

Permalink
chore: update Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Dec 12, 2023
1 parent 6aec2e7 commit 0150101
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 23 deletions.
51 changes: 28 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.222.0/containers/typescript-node/.devcontainer/Dockerfile

# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
ARG VARIANT=16-bullseye
ARG VARIANT=18-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT} as dev-env

# [Optional] Uncomment this section to install additional OS packages.
Expand All @@ -20,50 +20,50 @@ FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT} as dev-en

ENV PATH /usr/local/go/bin:$PATH

ENV GOLANG_VERSION 1.19.5
ENV GOLANG_VERSION 1.20.5

RUN set -eux; \
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
url=; \
case "$arch" in \
'amd64') \
url='https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz'; \
sha256='36519702ae2fd573c9869461990ae550c8c0d955cd28d2827a6b159fda81ff95'; \
url='https://dl.google.com/go/go1.20.5.linux-amd64.tar.gz'; \
sha256='d7ec48cde0d3d2be2c69203bc3e0a44de8660b9c09a6e85c4732a3f7dc442612'; \
;; \
'armel') \
export GOARCH='arm' GOARM='5' GOOS='linux'; \
;; \
'armhf') \
url='https://dl.google.com/go/go1.19.5.linux-armv6l.tar.gz'; \
sha256='ec14f04bdaf4a62bdcf8b55b9b6434cc27c2df7d214d0bb7076a7597283b026a'; \
url='https://dl.google.com/go/go1.20.5.linux-armv6l.tar.gz'; \
sha256='79d8210efd4390569912274a98dffc16eb85993cccdeef4d704e9b0dfd50743a'; \
;; \
'arm64') \
url='https://dl.google.com/go/go1.19.5.linux-arm64.tar.gz'; \
sha256='fc0aa29c933cec8d76f5435d859aaf42249aa08c74eb2d154689ae44c08d23b3'; \
url='https://dl.google.com/go/go1.20.5.linux-arm64.tar.gz'; \
sha256='aa2fab0a7da20213ff975fa7876a66d47b48351558d98851b87d1cfef4360d09'; \
;; \
'i386') \
url='https://dl.google.com/go/go1.19.5.linux-386.tar.gz'; \
sha256='f68331aa7458a3598060595f5601d5731fd452bb2c62ff23095ddad68854e510'; \
url='https://dl.google.com/go/go1.20.5.linux-386.tar.gz'; \
sha256='d394ac8fecf66812c78ffba7fb9a265bb1b9917564c7fd77f0edb0df6d5777a1'; \
;; \
'mips64el') \
export GOARCH='mips64le' GOOS='linux'; \
;; \
'ppc64el') \
url='https://dl.google.com/go/go1.19.5.linux-ppc64le.tar.gz'; \
sha256='e4032e7c52ebc48bad5c58ba8de0759b6091d9b1e59581a8a521c8c9d88dbe93'; \
url='https://dl.google.com/go/go1.20.5.linux-ppc64le.tar.gz'; \
sha256='049b8ab07d34077b90c0642138e10207f6db14bdd1743ea994a21e228f8ca53d'; \
;; \
's390x') \
url='https://dl.google.com/go/go1.19.5.linux-s390x.tar.gz'; \
sha256='764871cbca841a99a24e239b63c68a4aaff4104658e3165e9ca450cac1fcbea3'; \
url='https://dl.google.com/go/go1.20.5.linux-s390x.tar.gz'; \
sha256='bac14667f1217ccce1d2ef4e204687fe6191e6dc19a8870cfb81a41f78b04e48'; \
;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \
build=; \
if [ -z "$url" ]; then \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
build=1; \
url='https://dl.google.com/go/go1.19.5.src.tar.gz'; \
sha256='8e486e8e85a281fc5ce3f0bedc5b9d2dbf6276d7db0b25d3ec034f313da0375f'; \
url='https://dl.google.com/go/go1.20.5.src.tar.gz'; \
sha256='9a15c133ba2cfafe79652f4815b62e7cfc267f68df1b9454c6ab2a3ca8b96a88'; \
echo >&2; \
echo >&2 "warning: current architecture ($arch) does not have a compatible Go binary release; will be building from source"; \
echo >&2; \
Expand All @@ -88,8 +88,14 @@ RUN set -eux; \
\
if [ -n "$build" ]; then \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends golang-go; \
# add backports for newer go version for bootstrap build: https://github.com/golang/go/issues/44505
( \
. /etc/os-release; \
echo "deb https://deb.debian.org/debian $VERSION_CODENAME-backports main" > /etc/apt/sources.list.d/backports.list; \
\
apt-get update; \
apt-get install -y --no-install-recommends -t "$VERSION_CODENAME-backports" golang-go; \
); \
\
export GOCACHE='/tmp/gocache'; \
\
Expand All @@ -105,11 +111,6 @@ RUN set -eux; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*; \
\
# pre-compile the standard library, just like the official binary release tarballs do
go install std; \
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
# go install -race std; \
\
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
rm -rf \
/usr/local/go/pkg/*/cmd \
Expand Down Expand Up @@ -139,6 +140,10 @@ ENV GO111MODULE=auto
RUN bash /tmp/library-scripts/go-debian.sh "none" "/usr/local/go" "${GOPATH}" "node" "false" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install Terraform and Ansible to speed up agoric-sdk deployment tests
COPY library-scripts/install-terraform-ansible.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/install-terraform-ansible.sh

RUN rm -rf /tmp/library-scripts

# Add Tini
Expand Down
72 changes: 72 additions & 0 deletions library-scripts/install-terraform-ansible.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#! /bin/bash
set -ueo pipefail

# Install Terraform.
TERRAFORM_VERSION=0.11.14

uname_s=$(uname -s | tr '[:upper:]' '[:lower:]')

case $uname_s in
*) TERRAFORM_OS=$uname_s ;;
esac

uname_m=$(uname -m)
case $uname_m in
x86_64) TERRAFORM_ARCH=amd64 ;;
aarch64 | arm64) TERRAFORM_ARCH=arm ;;
*) TERRAFORM_ARCH=$uname_m ;;
esac

TERRAFORM_RELEASE=terraform_${TERRAFORM_VERSION}_${TERRAFORM_OS}_${TERRAFORM_ARCH}
TERRAFORM_URL=https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/${TERRAFORM_RELEASE}.zip

# Extract, then delete temporary file.
[ -f /usr/local/bin/terraform ] && (/usr/local/bin/terraform -version; true) | head -1 | grep -q "v$TERRAFORM_VERSION" || (
trap 'echo "Removing $terraform_zip"; rm -f "$terraform_zip"' EXIT
terraform_zip=$(mktemp -t terraformXXXXXX)
curl "$TERRAFORM_URL" > "$terraform_zip"
unzip -od /usr/local/bin/ "$terraform_zip"
)

VERSION_CODENAME_RAW="$(cat /etc/os-release | grep VERSION_CODENAME)"
VERSION_CODENAME=${VERSION_CODENAME_RAW#VERSION_CODENAME=}

# Debian version match
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-debian
case $VERSION_CODENAME in
jessie)
VERSION_CODENAME=trusty
;;
stretch)
VERSION_CODENAME=xenial
;;
buster)
VERSION_CODENAME=bionic
;;
bullseye)
VERSION_CODENAME=focal
;;
bookworm)
VERSION_CODENAME=jammy
;;
esac

# Install Ansible.
if test -d /etc/apt; then
dpkg-query -W ansible rsync curl sudo gnupg2 jq libbsd-dev >/dev/null || {
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu $VERSION_CODENAME main" > /etc/apt/sources.list.d/ansible.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
apt-get update --allow-releaseinfo-change -y
apt-get install -y ansible rsync curl sudo gnupg2 jq libbsd-dev
apt-get clean -y
}
elif test "$uname_s" == darwin; then
brew list ansible rsync curl gnupg2 jq >/dev/null || {
brew update
brew install ansible rsync curl gnupg2 jq
brew cleanup
}
else
echo "Don't know how to install Ansible, so I'm skipping..."
exit 1
fi

0 comments on commit 0150101

Please sign in to comment.