Dockerfile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. FROM mcr.microsoft.com/devcontainers/base:noble
  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 cloc software-properties-common && \
  5. \
  6. # Add PPA repository for nginx-extras
  7. add-apt-repository -y ppa:ondrej/nginx-mainline && \
  8. \
  9. # Update package information and install Nginx-extras
  10. apt-get update && \
  11. apt-get install -y --no-install-recommends nginx nginx-extras inotify-tools file && \
  12. \
  13. # Automatically retrieve the latest stable Go version and install it,
  14. # download the appropriate binary based on system architecture (amd64 or arm64)
  15. GO_VERSION=$(curl -sSL "https://golang.org/dl/?mode=json" | \
  16. jq -r 'map(select(.stable)) | .[0].version' | sed 's/^go//') && \
  17. ARCH=$(dpkg --print-architecture) && \
  18. if [ "$ARCH" = "arm64" ]; then \
  19. GO_ARCH=linux-arm64; \
  20. else \
  21. GO_ARCH=linux-amd64; \
  22. fi && \
  23. echo "Installing Go version: ${GO_VERSION} for architecture: ${GO_ARCH}" && \
  24. curl -sSL "https://golang.org/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz" -o go.tar.gz && \
  25. rm -rf /usr/local/go && \
  26. tar -C /usr/local -xzf go.tar.gz && \
  27. rm go.tar.gz
  28. RUN cp -rp /etc/nginx /etc/nginx.orig
  29. # Set PATH to include Go installation and default go install binary location
  30. ENV PATH="/usr/local/go/bin:/root/go/bin:${PATH}"
  31. # set zsh as default shell
  32. RUN chsh -s $(which zsh)