-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
189 lines (162 loc) · 7.16 KB
/
Dockerfile
File metadata and controls
189 lines (162 loc) · 7.16 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
FROM codercom/code-server:latest
ARG USER_UID=1000
ARG USER_GID=1000
ARG DOCKER_GID=1001
ARG PHP_VERSION=8.3
ARG NODE_MAJOR=22
ARG LANDO_VERSION=3.26.2
# --- Root operations: UID/GID adjustment and system packages ---
USER root
# Adjust coder user/group to match host UID/GID
RUN groupmod -g ${USER_GID} coder \
&& usermod -u ${USER_UID} -g ${USER_GID} coder \
&& chown -R ${USER_UID}:${USER_GID} /home/coder
# Create docker group matching host socket GID and add coder to it
RUN groupadd -g ${DOCKER_GID} docker \
&& usermod -aG docker coder
# System prerequisites
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
dnsmasq \
iproute2 \
git \
gnupg \
gosu \
libatomic1 \
lsb-release \
ca-certificates \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*
# Add Ondrej Sury PHP repository (Debian variant)
RUN curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /usr/share/keyrings/sury-php.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" \
> /etc/apt/sources.list.d/sury-php.list
# Install PHP and extensions
RUN apt-get update && apt-get install -y --no-install-recommends \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-zip \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-pgsql \
php${PHP_VERSION}-sqlite3 \
php${PHP_VERSION}-bcmath \
php${PHP_VERSION}-xdebug \
&& rm -rf /var/lib/apt/lists/*
# Install Composer via official installer
RUN curl -fsSL https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --filename=composer
# Add NodeSource repository
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash -
# Install Node.js and yarn
RUN apt-get update && apt-get install -y --no-install-recommends \
nodejs \
&& npm install -g yarn \
&& rm -rf /var/lib/apt/lists/*
# Install Python 3 and pip
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# Install uv (Python package manager)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
&& mv /root/.local/bin/uv /usr/local/bin/ \
&& mv /root/.local/bin/uvx /usr/local/bin/
# Install GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list \
&& apt-get update && apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*
# Install Docker CLI (connects to host Docker via mounted socket)
RUN curl -fsSL https://download.docker.com/linux/debian/gpg \
| gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -sc) stable" \
> /etc/apt/sources.list.d/docker.list \
&& apt-get update && apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin \
&& rm -rf /var/lib/apt/lists/*
# Install Drush Launcher
RUN curl -fsSL https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar \
-o /usr/local/bin/drush \
&& chmod +x /usr/local/bin/drush
# Install nvm (Node Version Manager) for switching Node versions per project
# PROFILE=/dev/null prevents nvm from modifying root's shell profiles during install;
# we add the source lines to coder's .bashrc manually below.
ARG NVM_VERSION=0.40.1
RUN mkdir -p /home/coder/.nvm \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh \
| NVM_DIR=/home/coder/.nvm PROFILE=/dev/null bash \
&& chown -R coder:coder /home/coder/.nvm
# Install Lando CLI (npm package; rename real binary so wrapper can replace it)
# Lando's plugin discovery looks in <core>/node_modules/@lando/, NOT in sibling global
# packages — so all recipe/service plugins must be installed as local deps inside core.
# Install a comprehensive set covering common Drupal 10 project stacks.
RUN npm install -g @lando/core@${LANDO_VERSION} \
&& cd $(npm root -g)/@lando/core && npm install \
@lando/drupal \
@lando/php \
@lando/mysql \
@lando/mariadb \
@lando/postgres \
@lando/nginx \
@lando/apache \
@lando/compose \
@lando/redis \
@lando/memcached \
@lando/solr \
@lando/elasticsearch \
@lando/varnish \
@lando/mailhog \
@lando/phpmyadmin \
@lando/node \
&& ln -sf $(npm root -g)/@lando/core/bin/lando /usr/local/bin/lando.real
# Install Claude Code globally as root so coder user doesn't need a global npm prefix.
# Installing it here keeps coder's .npmrc clean, avoiding nvm/prefix conflicts.
RUN npm install -g @anthropic-ai/claude-code
# Install path-translation wrapper as the 'lando' command
COPY lando-wrapper.sh /usr/local/bin/lando
RUN chmod +x /usr/local/bin/lando
# --- Switch to coder user for extensions and config ---
USER coder
# Set up PATH additions and nvm sourcing for interactive shells.
# No npm prefix is set — nvm manages per-version global installs;
# system-level tools (claude, lando, etc.) are installed as root above.
RUN echo 'export PATH="/home/ian/.lando/bin:$PATH"' >> /home/coder/.bashrc \
&& echo 'export PATH="/home/coder/code/src:$PATH"' >> /home/coder/.bashrc \
&& echo 'export NVM_DIR="/home/coder/.nvm"' >> /home/coder/.bashrc \
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /home/coder/.bashrc \
&& echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> /home/coder/.bashrc
ENV PATH="/home/coder/code/src:${PATH}"
# Pre-create directories to prevent bind-mounts from creating them as directories
RUN mkdir -p /home/coder/.local/share/code-server/User \
&& mkdir -p /home/coder/.claude \
&& touch /home/coder/.claude.json
# Install VS Code extensions from extensions.txt
COPY extensions.txt /home/coder/extensions.txt
RUN failed_exts=""; \
while IFS= read -r ext || [ -n "$ext" ]; do \
ext=$(echo "$ext" | sed 's/#.*//;s/^[[:space:]]*//;s/[[:space:]]*$//'); \
[ -z "$ext" ] && continue; \
if ! code-server --install-extension "$ext"; then \
echo "Failed to install VS Code extension: $ext" >&2; \
failed_exts="${failed_exts} $ext"; \
fi; \
done < /home/coder/extensions.txt; \
if [ -n "$failed_exts" ]; then \
echo "One or more VS Code extensions failed to install:${failed_exts}" >&2; \
exit 1; \
fi
# Switch back to root for entrypoint (drops to coder via gosu at runtime)
USER root
# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /home/coder/code
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "."]