-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
392 lines (332 loc) · 13.1 KB
/
Copy pathDockerfile
File metadata and controls
392 lines (332 loc) · 13.1 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# Copyright 2025 - Michael Sinz
# This is a multi-target Dockerfile - it is actually multiple build steps
# but related in that you may wish specific variations of the image.
# What this allows is for us to good build caching of common parts and also
# have reasonably good decomposition of the larger bits.
############ Base toolset install #############################################
FROM ubuntu:24.04 AS base
# The base tool install requires dotnet and then the tool itself.
# Note that this is basically a C-Sharp environment so we will be able to
# use it as such too. We also include git & rsync such that we can build CycoD
# and Powershell as SycoD likes to use it. Plus, we install make and gdb as
# they are useful in most all environments.
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
# We need to install .Net SDK which requires curl and lsb-release to get
# the Microsoft repo added to the apt repos. The SDK is needed for AI tool.
# It also happens to give us C# development capabilities.
ENV DEBIAN_FRONTEND=noninteractive
RUN <<INSTALL
echo "Base install"
set -e
set -x
# Now get ready for installing dotnet (since the tool needs it)
apt-get -qq update
apt-get install -y \
curl \
lsb-release \
software-properties-common
curl -L https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -o /tmp/packages-microsoft-prod.deb
dpkg -i /tmp/packages-microsoft-prod.deb
add-apt-repository ppa:dotnet/backports
# Now install:
# dotnet sdk 9.0 (required)
# git (required to build from git and to make local git commits)
# github (gh) (Just in case we need gh access)
# rsync (required when building from source)
apt-get -qq update
apt-get install -y \
bash \
bsdextrautils \
dotnet-sdk-9.0 \
file \
gdb \
gh \
git \
jq \
less \
make \
rsync \
vim \
zsh
# Powershell is useful as cycod likes to use it from time to time.
# Unfortunately, Powershell seems to be only available for the x86_64
# platform in the debian repo. This means that if we are not x86_64
# architecture we need to not try to install powershell as that will fail.
[ "$(arch)" != "x86_64" ] || apt-get install -y powershell
# This is where we default mount our work - just have it ready for use
# We really should make some way to do this a bit more "controlled"
mkdir -m 777 -p /workspace
# Cleanup the temporary stuff that is not actually needed
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
# Set our tool's bin directory and add it to the path
ARG AI_TOOL_BIN=/opt/ai/bin
ENV PATH=${AI_TOOL_BIN}:$PATH
# Set this to release, debug, git, or install. If "install" we
# will install the formal package rather than build from source/git.
# If "git" we will build from git branch/hash. If "release" or
# "debug" we build from the local source as a "release" or "debug" form.
ARG CYCOD_FROM=git
ARG CYCOD_BUILD=release
# Build cycod from source
ARG CYCOD_GIT=https://github.com/robch/cycod.git
# Set this to the branch you want to build from
ARG CYCOD_BRANCH=master
# Set hash to "any" to get the latest commit on the above branch
# Set hash to the hash you want to get a specific git commit point
#ARG CYCOD_HASH=ea5221bb786c2c67be73601046f8391d656a56cc
ARG CYCOD_HASH=any
RUN --mount=type=bind,source=./,target=/source/ \
<<BUILD
mkdir -m 755 -p ${AI_TOOL_BIN}
set -e
case "${CYCOD_FROM}" in
"package")
echo 'Installing from package ...'
dotnet tool install --tool-path ${AI_TOOL_BIN} CycoD --prerelease
;;
"git")
echo 'Building from git ...'
mkdir -p /build
cd /build
git clone --branch ${CYCOD_BRANCH} ${CYCOD_GIT} .
[ "${CYCOD_HASH}" = "any" ] || git checkout ${CYCOD_HASH}
dotnet build -c ${CYCOD_BUILD}
# This gathers up all of the build artifacts and puts them into the ${AI_TOOL_BIN}
rsync --verbose --checksum --ignore-existing --perms src/*/bin/*/net*/* ${AI_TOOL_BIN}/
cd /
;;
"source")
echo 'Building from local source ...'
mkdir -p /build
cp -a /source/. /build/.
cd /build
dotnet build -c ${CYCOD_BUILD}
# This gathers up all of the build artifacts and puts them into the ${AI_TOOL_BIN}
rsync --verbose --checksum --ignore-existing --perms src/*/bin/*/net*/* ${AI_TOOL_BIN}/
cd /
;;
*)
echo "Unknown CYCOD_FROM type: '${CYCOD_FROM}'"
exit 1
;;
esac
[ "${CLEANUP}" != "true" ] || rm -rf /build /root/.dotnet /root/.nuget /root/.local /tmp/* /tmp/.dotnet
chmod -R a-w,a+r ${AI_TOOL_BIN}
cycod --version
BUILD
############ Base toolset install =============================================
############ c-sharp #############################################
FROM base AS c-sharp
# Not much to do here other than being here...
############ c-cpp #############################################
FROM base AS c-cpp
# This is effectively an example C/C++ boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then gcc, g++, gdb, make, cmake, etc. With this you can use cycod
# and develop/test C, C++ (C# and PowerShell due to it being here for cycod)
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "c-cpp install"
set -e
set -x
apt-get -qq update
apt-get install -y \
cmake \
doxygen \
g++ \
gcc
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ rust ################################
FROM c-cpp AS rust
# This is effectively an example Rust boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then rustc, cargo, rustfmt, clippy, etc. With this you can use cycod
# and develop/test Rust (C# and PowerShell due to it being here for cycod)
# Rust also needs C and the linker
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
# Install rust - we want to use rustup for this as it gets newer rust versions
# We also skip installing rust documentation as it is large and not needed here.
# This happens to work in all Linux distros, so does not depend on if base image
# is a specific distro or not.
ENV RUSTUP_HOME=/usr/local/rustup
ENV PATH=/usr/local/cargo/bin:$PATH
RUN <<INSTALL_RUST
echo "Rust install"
set -e
set -x
cd /root
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /root/rust-install.sh
chmod +x /root/rust-install.sh
CARGO_HOME=/usr/local/cargo /root/rust-install.sh -y --profile minimal --component cargo,clippy,rust-std,rustc,rustfmt,llvm-tools-preview
[ "${CLEANUP}" != "true" ] || rm /root/rust-install.sh
INSTALL_RUST
############ nodejs #############################################
FROM base AS nodejs
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Node.js install"
set -e
set -x
apt-get -qq update
apt-get install -y \
nodejs \
npm
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ typescript #############################################
FROM nodejs AS typescript
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
# We may want typescript too!
RUN <<INSTALL_TYPESCRIPT
echo "Typescript install"
set -e
set -x
npm install -g typescript
[ "${CLEANUP}" != "true" ] || rm -rf /root/.npm
INSTALL_TYPESCRIPT
############ java #############################################
FROM base AS java
# This is effectively an example Java boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then the Java SDK (and make). With this you can use cycod
# and develop/test Java (C# and PowerShell due to it being here for cycod)
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Java install"
set -e
set -x
apt-get -qq update
apt-get install -y \
openjdk-21-jdk
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ python #############################################
FROM base AS python
# This is effectively an example Python boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then Python3 and pip (and make). With this you can use cycod
# and develop/test Python (C# and PowerShell due to it being here for cycod)
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Python install"
set -e
set -x
apt-get -qq update
apt-get install -y \
pip \
python3 \
python3-venv
[ -f /usr/bin/python ] || ln -s /usr/bin/python3 /usr/bin/python
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ go #############################################
FROM base AS go
# This is effectively an example Go boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then the Go sdk. With this you can use cycod
# and develop/test Go (C# and PowerShell due to it being here for cycod)
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Go install"
set -e
set -x
apt-get -qq update
apt-get install -y \
golang
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ ruby #############################################
FROM base AS ruby
# This is effectively an example Ruby boxed container for cycod
# It has dotnet (which cycod needs) and PowerShell (which it wants)
# and then Ruby. With this you can use cycod
# and develop/test Ruby (C# and PowerShell due to it being here for cycod)
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Ruby install"
set -e
set -x
apt-get -qq update
apt-get install -y \
ruby-full
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
############ large #############################################
FROM rust AS large
# This is the "large" Docker image for AI coding agent - it has many languages
# installed starting with the C# needd for the CycoD tools but then
# adding: C, C++, Rust, Java, golang, JavaScipt (nodejs), TypeScript, Perl,
# Python3, Ruby, and PowerShell (because CycoD uses it sometimes). We also
# include gdb for debugging, make and cmake for build coordination, file,
# rsync, git, and the normal Unix/Linux tools such as grep, sed, awk, etc.
#
# This is my go to contain - it is a bit big but I have it cached locally and
# I don't have to think about which type of tool or coding I need to work with
# as it supports many of them. (Yes, I skipped many too but these are top of
# mind these days.) We really don't need all of these but this
# container is the "Swiss Army Knife" of AI coding containers.
#
# We start from the rust image as it already has rust and C/C++ in it.
# Now we add the rest of the stuff.
# If set to true, we try to clean up any temp items and build directories
# such that the image is smaller.
ARG CLEANUP=true
RUN <<INSTALL
echo "Large install"
set -e
set -x
apt-get -qq update
apt-get install -y \
cmake \
doxygen \
g++ \
gcc \
golang \
less \
nodejs \
npm \
openjdk-21-jdk \
pip \
python3 \
python3-venv \
ruby-full \
vim
[ -f /usr/bin/python ] || ln -s /usr/bin/python3 /usr/bin/python
[ "${CLEANUP}" != "true" ] || apt-get clean all
[ "${CLEANUP}" != "true" ] || rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* /tmp/*
INSTALL
# We may want typescript too!
RUN <<INSTALL_TYPESCRIPT
echo "Typescript install"
set -e
set -x
npm install -g typescript
[ "${CLEANUP}" != "true" ] || rm -rf /root/.npm
INSTALL_TYPESCRIPT