-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (62 loc) · 2.81 KB
/
Dockerfile
File metadata and controls
77 lines (62 loc) · 2.81 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
# Modify these to suit your needs
FROM debian:trixie
ARG USER_NAME=fortes \
USER_ID=1000 \
GROUP_ID=1000 \
TZ=America/New_York \
DEBIAN_FRONTEND=noninteractive
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
TZ=$TZ
# Share the apt manifest with setup_linux so this layer only rebuilds when the package
# list changes. That keeps apt downloads cached between Docker builds.
COPY script/apt-packages.txt /tmp/apt-packages.txt
# Enable contrib/non-free and backports before installing packages so that
# every environment (Docker or host) sees the same repositories. Install all
# base packages in a single layer, then purge apt caches so we don't carry
# ~100 MB of metadata into later layers.
RUN set -eux; \
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"; \
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i 's/Components: main$/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources; \
else \
sed -i 's/main$/main contrib non-free non-free-firmware/' /etc/apt/sources.list; \
fi; \
printf '%s\n' \
'Types: deb' \
'URIs: http://deb.debian.org/debian' \
"Suites: ${codename}-backports" \
'Components: main contrib non-free non-free-firmware' \
'Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg' \
> /etc/apt/sources.list.d/backports.sources; \
apt-get -qqy update; \
awk 'NF && $1 !~ /^#/' /tmp/apt-packages.txt | xargs -r apt-get install -qq --no-install-recommends -y; \
rm -rf /var/lib/apt/lists/* /tmp/apt-packages.txt
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
# Don't require password for `sudo` use
RUN echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/10-docker-nopasswd
RUN groupadd --gid $GROUP_ID $USER_NAME && \
useradd --uid $USER_ID --gid $GROUP_ID \
--home-dir /home/$USER_NAME --create-home \
--shell /bin/bash $USER_NAME && \
usermod -aG sudo $USER_NAME
USER $USER_NAME
WORKDIR /home/$USER_NAME
# Create /workspaces directory for projects and Claude config
RUN sudo mkdir -p /workspaces && sudo chown $USER_NAME:$USER_NAME /workspaces
# Copy only scripts needed for package installation (heavy layer, rarely changes)
COPY --chown=$USER_NAME:$USER_NAME script/ /home/$USER_NAME/dotfiles/script/
ENV IS_DOCKER=1 \
SKIP_INITIAL_APT_INSTALL=1 \
CLAUDE_CONFIG_DIR=/workspaces/.claude-container
# Install all packages and clean up in same layer to reduce image size
RUN ./dotfiles/script/setup && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy all dotfiles including stowed-files/ (cheap, but invalidates on config changes)
COPY --chown=$USER_NAME:$USER_NAME . /home/$USER_NAME/dotfiles/
# Re-run stow to pick up any config changes (fast)
RUN ./dotfiles/script/stow
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]