|
| 1 | +FROM mcr.microsoft.com/devcontainers/base:jammy |
| 2 | + |
| 3 | +# Combine installation steps for Nginx and Go to avoid repetitive update/cleanup commands |
| 4 | +RUN apt-get update && \ |
| 5 | + apt-get install -y --no-install-recommends curl gnupg2 ca-certificates lsb-release ubuntu-keyring jq && \ |
| 6 | + \ |
| 7 | + # Configure the Nginx repository |
| 8 | + curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg && \ |
| 9 | + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx" \ |
| 10 | + > /etc/apt/sources.list.d/nginx.list && \ |
| 11 | + printf "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ |
| 12 | + > /etc/apt/preferences.d/99nginx && \ |
| 13 | + \ |
| 14 | + # Update package information and install Nginx |
| 15 | + apt-get update && \ |
| 16 | + apt-get install -y --no-install-recommends nginx && \ |
| 17 | + \ |
| 18 | + # Install the latest Node.js via NodeSource setup script |
| 19 | + curl -fsSL https://deb.nodesource.com/setup_current.x | bash - && \ |
| 20 | + apt-get update && \ |
| 21 | + apt-get install -y nodejs && \ |
| 22 | + \ |
| 23 | + # Install pnpm globally using npm |
| 24 | + npm install -g pnpm && \ |
| 25 | + \ |
| 26 | + # Automatically retrieve the latest stable Go version and install it, |
| 27 | + # download the appropriate binary based on system architecture (amd64 or arm64) |
| 28 | + GO_VERSION=$(curl -sSL "https://golang.org/dl/?mode=json" | \ |
| 29 | + jq -r 'map(select(.stable)) | .[0].version' | sed 's/^go//') && \ |
| 30 | + ARCH=$(dpkg --print-architecture) && \ |
| 31 | + if [ "$ARCH" = "arm64" ]; then \ |
| 32 | + GO_ARCH=linux-arm64; \ |
| 33 | + else \ |
| 34 | + GO_ARCH=linux-amd64; \ |
| 35 | + fi && \ |
| 36 | + echo "Installing Go version: ${GO_VERSION} for architecture: ${GO_ARCH}" && \ |
| 37 | + curl -sSL "https://golang.org/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz" -o go.tar.gz && \ |
| 38 | + rm -rf /usr/local/go && \ |
| 39 | + tar -C /usr/local -xzf go.tar.gz && \ |
| 40 | + rm go.tar.gz && \ |
| 41 | + \ |
| 42 | + # Remove jq and clean up to reduce image size |
| 43 | + apt-get remove -y jq && \ |
| 44 | + apt-get autoremove -y && \ |
| 45 | + apt-get clean && \ |
| 46 | + rm -rf /var/lib/apt/lists/* |
| 47 | + |
| 48 | +RUN cp -rp /etc/nginx /etc/nginx.orig |
| 49 | + |
| 50 | +# Set PATH to include Go installation and default go install binary location |
| 51 | +ENV PATH="/usr/local/go/bin:/root/go/bin:${PATH}" |
| 52 | + |
| 53 | +# Install air with go install (requires Go 1.23 or higher) |
| 54 | +RUN go install github.com/air-verse/air@latest |
| 55 | + |
| 56 | +# set zsh as default shell |
| 57 | +RUN chsh -s $(which zsh) |
0 commit comments