Skip to content

Commit 7008747

Browse files
author
mujing
committed
build: add sha tag and update language versions
1 parent cd80b3d commit 7008747

6 files changed

Lines changed: 58 additions & 44 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
tags: |
5555
type=raw,value=latest,enable={{is_default_branch}}
5656
type=sha,format=short
57+
type=raw,value=${{ github.sha }}
5758
type=raw,value=${{ env.DATE_TAG }}
5859
5960
- name: Build and push by digest
@@ -124,6 +125,7 @@ jobs:
124125
tags: |
125126
type=raw,value=latest,enable={{is_default_branch}}
126127
type=sha,format=short
128+
type=raw,value=${{ github.sha }}
127129
type=raw,value=${{ env.DATE_TAG }}
128130
129131
- name: Create manifest list and push
@@ -168,9 +170,6 @@ jobs:
168170
run: |
169171
echo "IMAGE_NAME=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
170172
171-
- name: Get current date for tagging
172-
run: echo "DATE_TAG=$(date +'%Y%m%d')" >> $GITHUB_ENV
173-
174173
- name: Log in to the Container registry
175174
uses: docker/login-action@v3
176175
with:
@@ -179,10 +178,10 @@ jobs:
179178
password: ${{ secrets.GITHUB_TOKEN }}
180179

181180
- name: Pull image
182-
run: docker pull ${{ env.IMAGE_NAME }}:${{ env.DATE_TAG }}
181+
run: docker pull ${{ env.IMAGE_NAME }}:${{ github.sha }}
183182

184183
- name: Start test container
185-
run: docker run -d --name test-container ${{ env.IMAGE_NAME }}:${{ env.DATE_TAG }} sleep 600
184+
run: docker run -d --name test-container ${{ env.IMAGE_NAME }}:${{ github.sha }} sleep 600
186185

187186
- name: Test default user is coder
188187
timeout-minutes: 1
@@ -275,7 +274,8 @@ jobs:
275274
if docker exec test-container bash -c "sudo su - root" 2>&1 | grep -q "sudo: su: command not found\|Sorry, user coder is not allowed to execute"; then
276275
echo "✓ su command is properly blocked"
277276
else
278-
echo "::warning::su command might not be properly blocked"
277+
echo "::error::su command is not blocked as expected"
278+
exit 1
279279
fi
280280
281281
- name: Test mirror configurations

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ ide-code-server/
2727
## What the Image Installs
2828

2929
### Language runtimes
30-
- Go `1.24.0`
30+
- Go `1.26.1`
3131
- Python `3.13` (Miniforge/conda)
3232
- Node.js `22` LTS
3333
- JDK `21` (Temurin)
3434
- Maven `3.9.11`
35-
- Ruby `3.4.4` via `rbenv`
35+
- Ruby `4.0.2` via `rbenv`
3636

3737
### Core tools
3838
- System: `git`, `curl`, `wget`, `vim`, `tmux`, `dnsutils`, `yq`, `kubectl`, `sudo`

Dockerfile

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN mkdir -p /etc/apt/keyrings \
2727
&& chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg \
2828
&& echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list \
2929
&& apt-get update \
30-
&& apt-get install -y kubectl \
30+
&& apt-get install -y --no-install-recommends kubectl \
3131
&& rm -rf /var/lib/apt/lists/*
3232

3333
# Layer 2: User permissions - sudo with su blocked
@@ -37,25 +37,35 @@ RUN apt-get update && apt-get install -y --no-install-recommends sudo \
3737
&& visudo -c -f /etc/sudoers.d/coder-nopasswd \
3838
&& rm -rf /var/lib/apt/lists/*
3939

40-
# Layer 3: Go (latest) with China mirror and tools
41-
ENV GO_VERSION=1.24.0
40+
# Layer 3: Go (pinned stable) with China mirror and tools
41+
ENV GO_VERSION=1.26.1
42+
ENV GO_SHA256_AMD64=031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a
43+
ENV GO_SHA256_ARM64=a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7
4244
ENV GOPROXY=https://goproxy.cn,direct
4345
# GOPATH for user packages (can be mounted), tools installed to /opt/go-tools
4446
ENV GOPATH=/home/coder/go
4547
ENV GO_TOOLS_PATH=/opt/go-tools
4648
ENV PATH=/usr/local/go/bin:/opt/go-tools/bin:/home/coder/go/bin:$PATH
4749

4850
RUN ARCH=$(dpkg --print-architecture) \
49-
&& curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz | tar -C /usr/local -xzf - \
51+
&& case "$ARCH" in \
52+
amd64) GO_SHA256="$GO_SHA256_AMD64" ;; \
53+
arm64) GO_SHA256="$GO_SHA256_ARM64" ;; \
54+
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
55+
esac \
56+
&& curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o /tmp/go.tgz \
57+
&& echo "${GO_SHA256} /tmp/go.tgz" | sha256sum -c - \
58+
&& rm -rf /usr/local/go \
59+
&& tar -C /usr/local -xzf /tmp/go.tgz \
60+
&& rm -f /tmp/go.tgz \
5061
&& go version
5162

5263
# Install Go tools to /opt/go-tools (not affected by volume mounts on /home/coder)
53-
RUN mkdir -p /opt/go-tools \
54-
&& GOPATH=/opt/go-tools go install golang.org/x/tools/gopls@latest \
55-
&& GOPATH=/opt/go-tools go install github.com/go-delve/delve/cmd/dlv@latest \
56-
&& GOPATH=/opt/go-tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest \
57-
&& GOPATH=/opt/go-tools go install golang.org/x/tools/cmd/goimports@latest \
58-
&& chown -R coder:coder /opt/go-tools
64+
RUN install -d -o coder -g coder /opt/go-tools \
65+
&& sudo -u coder env GOPATH=/opt/go-tools go install golang.org/x/tools/gopls@latest \
66+
&& sudo -u coder env GOPATH=/opt/go-tools go install github.com/go-delve/delve/cmd/dlv@latest \
67+
&& sudo -u coder env GOPATH=/opt/go-tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest \
68+
&& sudo -u coder env GOPATH=/opt/go-tools go install golang.org/x/tools/cmd/goimports@latest
5969

6070
# Create symlinks for go commands (ensures availability even when PATH is reset)
6171
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go \
@@ -65,18 +75,21 @@ RUN ln -s /usr/local/go/bin/go /usr/local/bin/go \
6575
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
6676

6777
# Install Miniforge (conda-forge based, no Anaconda ToS required)
68-
RUN ARCH=$(dpkg --print-architecture) && \
78+
RUN install -d -o coder -g coder /opt/conda \
79+
&& ARCH=$(dpkg --print-architecture) && \
6980
if [ "$ARCH" = "amd64" ]; then CONDA_ARCH="x86_64"; \
7081
elif [ "$ARCH" = "arm64" ]; then CONDA_ARCH="aarch64"; \
7182
else CONDA_ARCH="$ARCH"; fi && \
7283
curl -fsSL https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${CONDA_ARCH}.sh -o /tmp/miniforge.sh \
73-
&& bash /tmp/miniforge.sh -b -p /opt/conda \
84+
&& chmod +x /tmp/miniforge.sh \
85+
&& sudo -u coder bash /tmp/miniforge.sh -b -p /opt/conda \
7486
&& rm /tmp/miniforge.sh
7587
ENV PATH=/opt/conda/bin:$PATH
7688

7789
# Install Python 3.13 via conda-forge and create symlinks
78-
RUN conda install -y python=3.13 \
79-
&& conda clean -afy \
90+
RUN sudo -u coder /opt/conda/bin/conda install -y python=3.13 \
91+
&& sudo -u coder /opt/conda/bin/conda config --set show_channel_urls yes \
92+
&& sudo -u coder /opt/conda/bin/conda clean -afy \
8093
&& ln -sf /opt/conda/bin/python /usr/bin/python3 \
8194
&& ln -sf /opt/conda/bin/python /usr/bin/python \
8295
&& ln -sf /opt/conda/bin/pip /usr/bin/pip3 \
@@ -90,12 +103,13 @@ ENV NODE_VERSION=22
90103

91104
# Install Node.js from NodeSource
92105
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
93-
&& apt-get install -y nodejs \
106+
&& apt-get install -y --no-install-recommends nodejs \
94107
&& rm -rf /var/lib/apt/lists/*
95108

96109
# Configure npm mirror and install pnpm, yarn, iflow-cli, claude-code
97110
RUN npm config set registry https://registry.npmmirror.com --global \
98111
&& npm install -g pnpm yarn @iflow-ai/iflow-cli@latest @anthropic-ai/claude-code@latest \
112+
&& npm cache clean --force \
99113
&& pnpm config set registry https://registry.npmmirror.com \
100114
&& yarn config set registry https://registry.npmmirror.com
101115

@@ -124,6 +138,8 @@ RUN ln -s /opt/temurin-21-jdk/bin/java /usr/local/bin/java \
124138
# Layer 7: Ruby (rbenv) + Rails with Ruby China mirror
125139
# Install rbenv to /opt/rbenv to avoid being overwritten by volume mounts
126140
ENV RBENV_ROOT=/opt/rbenv
141+
ENV RUBY_VERSION=4.0.2
142+
ENV RUBY_GEM_ABI=4.0.0
127143
ENV PATH=$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH
128144

129145
# Install Ruby dependencies
@@ -142,16 +158,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
142158
&& rm -rf /var/lib/apt/lists/*
143159

144160
# Install rbenv and ruby-build to /opt/rbenv (system path, not affected by volume mounts)
145-
RUN git clone https://github.com/rbenv/rbenv.git /opt/rbenv \
146-
&& git clone https://github.com/rbenv/ruby-build.git /opt/rbenv/plugins/ruby-build
161+
RUN git clone --depth 1 https://github.com/rbenv/rbenv.git /opt/rbenv \
162+
&& git clone --depth 1 https://github.com/rbenv/ruby-build.git /opt/rbenv/plugins/ruby-build \
163+
&& chown -R coder:coder /opt/rbenv
147164

148165
# Install latest stable Ruby and Rails
149-
RUN /opt/rbenv/plugins/ruby-build/install.sh \
150-
&& rbenv install 3.4.4 \
151-
&& rbenv global 3.4.4 \
166+
RUN sudo -u coder env RUBY_VERSION=${RUBY_VERSION} bash -lc 'set -euo pipefail \
167+
&& export RBENV_ROOT=/opt/rbenv \
168+
&& export PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH" \
169+
&& /opt/rbenv/plugins/ruby-build/install.sh \
170+
&& rbenv install "$RUBY_VERSION" \
171+
&& rbenv global "$RUBY_VERSION" \
152172
&& rbenv rehash \
153173
&& gem install bundler rails --no-document \
154-
&& rbenv rehash
174+
&& rbenv rehash'
155175

156176
# Configure gem mirror
157177
RUN echo "---\n:sources:\n - https://gems.ruby-china.com/" > /home/coder/.gemrc
@@ -175,7 +195,8 @@ RUN echo '\n\
175195
export PATH=/opt/go-tools/bin:/opt/rbenv/bin:/opt/rbenv/shims:/opt/temurin-21-jdk/bin:/opt/conda/bin:/usr/local/go/bin:/home/coder/go/bin:$PATH\n\
176196
\n\
177197
# User-installed gem executables path\n\
178-
export PATH=/home/coder/.local/share/gem/ruby/3.4.0/bin:$PATH\n\
198+
export RUBY_GEM_ABI=${RUBY_GEM_ABI:-4.0.0}\n\
199+
export PATH=/home/coder/.local/share/gem/ruby/${RUBY_GEM_ABI}/bin:$PATH\n\
179200
\n\
180201
# Initialize rbenv\n\
181202
if [ -x /opt/rbenv/bin/rbenv ]; then\n\
@@ -228,16 +249,8 @@ RUN cp /opt/dev-configs/gemrc /home/coder/.gemrc \
228249
&& cp /opt/dev-configs/pip.conf /home/coder/.config/pip/pip.conf \
229250
&& cat /opt/dev-configs/bashrc-append.sh >> /home/coder/.bashrc
230251

231-
# conda config - Miniforge uses conda-forge by default (no Anaconda ToS)
232-
RUN /opt/conda/bin/conda config --set show_channel_urls yes
233-
234252
# Set ownership for coder user
235-
RUN chown -R coder:coder /home/coder \
236-
&& chown -R coder:coder /opt/conda \
237-
&& chown -R coder:coder /opt/go-tools \
238-
&& chown -R coder:coder /opt/rbenv/versions \
239-
&& chown -R coder:coder /opt/rbenv/shims \
240-
&& chown coder:coder /opt/rbenv/version
253+
RUN chown -R coder:coder /home/coder
241254

242255
# Create entrypoint script that initializes home directory on container start
243256
# This ensures configs are properly set when /home/coder is mounted externally

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ The following components are installed in system directories and remain availabl
177177

178178
| Language | Version | Tools | Mirror |
179179
|----------|---------|-------|--------|
180-
| Go | 1.24.0 | gopls, delve, golangci-lint | goproxy.cn |
180+
| Go | 1.26.1 | gopls, delve, golangci-lint | goproxy.cn |
181181
| Python | 3.13 | uv, conda | pypi.tuna.tsinghua.edu.cn |
182182
| Node.js | 22 LTS | npm, pnpm, yarn | npmmirror |
183183
| JDK | 21 | Maven 3.9.11 | Aliyun |
184-
| Ruby | 3.4.4 | Rails, Bundler | Ruby China |
184+
| Ruby | 4.0.2 | Rails, Bundler | Ruby China |
185185

186186
## Build
187187

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ docker run -d \
177177

178178
| 语言 | 版本 | 工具 | 镜像 |
179179
|----------|---------|-------|--------|
180-
| Go | 1.24.0 | gopls, delve, golangci-lint | goproxy.cn |
180+
| Go | 1.26.1 | gopls, delve, golangci-lint | goproxy.cn |
181181
| Python | 3.13 | uv, conda | pypi.tuna.tsinghua.edu.cn |
182182
| Node.js | 22 LTS | npm, pnpm, yarn | npmmirror |
183183
| JDK | 21 | Maven 3.9.11 | Aliyun |
184-
| Ruby | 3.4.4 | Rails, Bundler | Ruby China |
184+
| Ruby | 4.0.2 | Rails, Bundler | Ruby China |
185185

186186
## 构建
187187

scripts/init-home.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ set -e
77
HOME_DIR="${HOME_DIR:-/home/coder}"
88
CONFIG_TEMPLATES="${CONFIG_TEMPLATES:-/opt/dev-configs}"
99
RBENV_ROOT="${RBENV_ROOT:-/opt/rbenv}"
10+
RUBY_GEM_ABI="${RUBY_GEM_ABI:-4.0.0}"
1011

1112
# Create necessary directories
1213
echo "Creating directories..."
1314
mkdir -p "$HOME_DIR/project"
1415
mkdir -p "$HOME_DIR/.local/share/code-server"
1516
mkdir -p "$HOME_DIR/.local/share/pnpm"
16-
mkdir -p "$HOME_DIR/.local/share/gem/ruby/3.4.0/bin"
17+
mkdir -p "$HOME_DIR/.local/share/gem/ruby/$RUBY_GEM_ABI/bin"
1718
mkdir -p "$HOME_DIR/.m2/repository"
1819
mkdir -p "$HOME_DIR/.config/pip"
1920
mkdir -p "$HOME_DIR/.npm"

0 commit comments

Comments
 (0)