-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
87 lines (77 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
87 lines (77 loc) · 2.07 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
FROM alpine:3.23
LABEL maintainer="Backplane BV <backplane@users.noreply.github.com>"
RUN apk add --no-cache \
bash \
ca-certificates \
cargo \
curl \
docker-cli \
docker-cli-compose \
gcc \
git \
go \
gpg \
jq \
libgcc \
libstdc++ \
libxml2-utils \
musl \
openssh-client \
patch \
perl \
pnpm \
rage \
ripgrep \
rsync \
shellcheck \
uv \
yq-go \
zstd \
;
# get the first stage installer script, make some light edits
ARG INSTALLER=/var/claude-install.sh
RUN set -eux; \
curl -fsSL -o "${INSTALLER}" https://claude.ai/install.sh; \
chmod a=r "${INSTALLER}"; \
perl -i \
-e 's/^set -e$/set -ex/;' \
-e 's/^(\s*rm -f) /\1 -v /;' \
"${INSTALLER}";
# create a non-root user
ARG NONROOT_GID=65532
ARG NONROOT_UID=65532
ARG NONROOT_HOME="/home/nonroot"
ARG NONROOT_SKEL="/.nonroot_skeleton"
RUN set -eux; \
addgroup -g "${NONROOT_GID}" nonroot; \
adduser -u "${NONROOT_UID}" -G nonroot \
-s "/bin/bash" \
-h "${NONROOT_HOME}" \
-D \
nonroot; \
for d in \
"/work" \
"${NONROOT_HOME}/.claude" \
"${NONROOT_SKEL}" \
; do \
mkdir -m "0770" -p "$d"; \
chown "nonroot:nonroot" "$d"; \
done;
USER nonroot
WORKDIR /work
# add ~nonroot/.local/bin to the search path
ENV PATH="${NONROOT_HOME}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# install claude (as non-root)
ARG INSTALL_LOG="${NONROOT_HOME}/.claude-install-log.txt"
RUN set -eux; \
bash "$INSTALLER" 2>&1 | tee "$INSTALL_LOG"; \
gzip -9 "$INSTALL_LOG";
# see https://code.claude.com/docs/en/memory#claude-md-files
# this one advises about the tools that are locally installed
COPY --chown=nonroot:nonroot skel-CLAUDE.md "${NONROOT_HOME}/.claude/CLAUDE.md"
# copy (via hard link) the nonroot homedir to a skeleton dir, so that if a volume
# is placed over the nonroot homedir, that volume gets a copy of the contents of
# the skeleton
RUN cp -al "${NONROOT_HOME}/." "${NONROOT_SKEL}/";
COPY --chown=root:root entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]