FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y \
        sudo \
        curl \
        git \
        ca-certificates \
        build-essential && \
    apt-get clean

# Install Go
ENV GO_VERSION=1.22.3
RUN curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xz

ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/home/1001/go"
ENV PATH="${GOPATH}/bin:${PATH}"

# Install code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh -s -- --version=4.98.0

# Safe for Ubuntu + RHEL images
RUN chmod -R ug+w /etc/pki/ca-trust/source /etc/pki/ca-trust/extracted || true

RUN useradd -m -u 1001 devuser
USER 1001
WORKDIR /home/1001

CMD ["tail", "-f", "/dev/null"]
