Customizing a code-server Docker Image

The Problem: code-server docker container comes with 0 binaries, so you have to set it up to your specific needs in a Dockerfile to include the binaries and packages you need for development assuming you’re using the built-in terminal and proxied port forwarding, etc. The Solution: Write a Dockerfile.

This is the most I have touched a dockerfile. It seems to work though. There may be better ways of doing this, but it’s working for now!

 1FROM ghcr.io/coder/code-server:latest
 2USER root
 3
 4# Install from package manager
 5RUN apt-get update && apt-get install -y \
 6    build-essential \
 7    software-properties-common \
 8    git \
 9    curl \
10    unzip \
11    wget \
12    sqlite3 \
13    libsqlite3-dev \
14    python3 \
15    python3-pip \
16    python3-venv \
17    docker.io \
18    && rm -rf /var/lib/apt/lists/*
19
20# Install Golang
21ARG GO_VERSION=1.26.0
22RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
23tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
24rm go${GO_VERSION}.linux-amd64.tar.gz
25
26# Install Hugo
27ARG HUGO_VERSION=0.156.0
28RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb && \
29dpkg -i hugo_extended_${HUGO_VERSION}_linux-amd64.deb && \
30rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb
31
32USER coder
33
34ENV PATH="/usr/local/go/bin:${PATH}"
35
36RUN go version
37RUN python3 --version
38RUN gcc --version
39RUN sqlite3 --version
40RUN hugo version
41
42CMD ["code-server"]

tags: dockercodedockerfile