-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.codeserver
More file actions
149 lines (125 loc) · 4.55 KB
/
Copy pathDockerfile.codeserver
File metadata and controls
149 lines (125 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Dockerfile.codeserver
# Build code-server from official .deb releases
# Source: https://github.com/coder/code-server
# Releases: https://github.com/coder/code-server/releases
# syntax=docker/dockerfile:1.7
ARG BASE=debian:13
FROM ${BASE}
ARG CODESERVER_VERSION=4.123.0
ARG TARGETARCH
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
dumb-init \
git \
git-lfs \
htop \
locales \
lsb-release \
nano \
openssh-client \
procps \
sudo \
vim-tiny \
wget \
zsh \
&& git lfs install \
&& rm -rf /var/lib/apt/lists/*
# Locale setup
RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen \
&& locale-gen
ENV LANG=en_US.UTF-8
# Create coder user
RUN if grep -q 1000 /etc/passwd; then \
userdel -r "$(id -un 1000)"; \
fi \
&& adduser --gecos '' --disabled-password coder \
&& mkdir -p /etc/sudoers.d \
&& echo "coder ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nopasswd \
&& chmod 0440 /etc/sudoers.d/nopasswd \
&& mkdir -p /var/log/codeserver-ai \
&& chown coder:coder /var/log/codeserver-ai
# Install fixuid
RUN ARCH="$(dpkg --print-architecture)" \
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" \
| tar -C /usr/local/bin -xzf - \
&& chown root:root /usr/local/bin/fixuid \
&& chmod 4755 /usr/local/bin/fixuid \
&& mkdir -p /etc/fixuid \
&& printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
# Download and install code-server .deb from GitHub releases
RUN DEB_ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" \
&& curl -fsSL \
"https://github.com/coder/code-server/releases/download/v${CODESERVER_VERSION}/code-server_${CODESERVER_VERSION}_${DEB_ARCH}.deb" \
-o /tmp/code-server.deb \
&& PACKAGE_ARCH="$(dpkg-deb -f /tmp/code-server.deb Architecture)" \
&& SYSTEM_ARCH="$(dpkg --print-architecture)" \
&& if [ "$PACKAGE_ARCH" != "$SYSTEM_ARCH" ]; then \
echo "code-server package architecture mismatch: package=$PACKAGE_ARCH system=$SYSTEM_ARCH" >&2; \
exit 1; \
fi \
&& dpkg -i /tmp/code-server.deb \
&& rm /tmp/code-server.deb
# Install AWS CLI and PostgreSQL client for backup/restore
RUN apt-get update && apt-get install -y --no-install-recommends \
groff \
less \
postgresql-client \
python3-pip \
&& pip3 install --break-system-packages --root-user-action=ignore awscli \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js LTS and OpenCode CLI for terminal usage
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g opencode-ai@latest \
&& npm cache clean --force \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Inject mobile CSS into code-server HTML
COPY config/code-server/custom/mobile.css /tmp/code-server-mobile.css
RUN node - <<'NODE'
const fs = require('fs');
const path = require('path');
const css = fs.readFileSync('/tmp/code-server-mobile.css', 'utf8');
const style = `<style id="codeserver-mobile-responsive">\n${css}\n</style>`;
const files = [];
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
walk(fullPath);
} else if (entry.isFile() && entry.name.endsWith('.html')) {
files.push(fullPath);
}
}
}
walk('/usr/lib/code-server');
let patched = 0;
for (const file of files) {
const html = fs.readFileSync(file, 'utf8');
if (html.includes('</head>') && !html.includes('codeserver-mobile-responsive')) {
fs.writeFileSync(file, html.replace('</head>', `${style}</head>`));
patched += 1;
}
}
if (patched === 0) {
throw new Error('No code-server HTML files found');
}
NODE
# Copy custom scripts and config
COPY scripts/ /scripts/
RUN chmod +x /scripts/*.sh
COPY config/code-server/config.yaml /home/coder/.config/code-server/config.yaml
COPY config/code-server/settings.json /home/coder/.config/code-server/User/settings.json
COPY config/code-server/keybindings.json /home/coder/.config/code-server/User/keybindings.json
RUN mkdir -p /workspace/.memory /var/log/codeserver-ai \
&& chown -R coder:coder /home/coder/.config /workspace /var/log/codeserver-ai
EXPOSE 8443
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8443 || exit 1
USER coder
ENV USER=coder
WORKDIR /home/coder
ENTRYPOINT ["/scripts/init.sh"]