Dockerfile 2.3 KB

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