Skip to content

Commit 5dd16f3

Browse files
committed
update dockerfile
1 parent bfad48f commit 5dd16f3

12 files changed

Lines changed: 156 additions & 151 deletions

File tree

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// Shared Dockerfile partials live in ports/_common/*.dockerfile and are raw
3+
// Dockerfile content (plus a few Go-template directives), so highlight them
4+
// as Dockerfiles even though VS Code does not associate the extension by default.
5+
"files.associations": {
6+
"*.dockerfile": "dockerfile"
7+
}
8+
}

ports/_common/apt.dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
2+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
3+
rm -f /etc/apt/apt.conf.d/docker-clean \
4+
&& export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get update \
6+
&& apt-get install -y --no-install-recommends \
7+
apt-transport-https \
8+
bash \
9+
bash-completion \
10+
build-essential \
11+
ca-certificates \
12+
curl \
13+
dirmngr \
14+
eza \
15+
fd-find \
16+
git \
17+
git-lfs \
18+
gnupg2 \
19+
htop \
20+
init-system-helpers \
21+
iproute2 \
22+
jq \
23+
less \
24+
libc6 \
25+
libgcc1 \
26+
libgssapi-krb5-2 \
27+
libicu[0-9][0-9] \
28+
libkrb5-3 \
29+
libstdc++6 \
30+
locales \
31+
lsb-release \
32+
lsof \
33+
make \
34+
man-db \
35+
manpages \
36+
manpages-dev \
37+
ncdu \
38+
openssh-client \
39+
procps \
40+
psmisc \
41+
{{- if .SystemPython }}
42+
python3 \
43+
python3-pip \
44+
{{- end }}
45+
ripgrep \
46+
rsync \
47+
strace \
48+
sudo \
49+
tmux \
50+
tzdata \
51+
unzip \
52+
vim \
53+
wget \
54+
zip \
55+
zlib1g \
56+
zsh \
57+
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
58+
&& locale-gen
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
USER root
2+
WORKDIR /
3+
4+
# Mount point for a persisted command-history volume. Created with USERNAME
5+
# ownership so a fresh named volume inherits it on first mount.
6+
RUN install -d -o "${USERNAME}" -g "${USERNAME}" /commandhistory

ports/_common/dockerfile.tmpl

Lines changed: 0 additions & 128 deletions
This file was deleted.

ports/_common/node.dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
2+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
3+
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
4+
&& apt-get install -y --no-install-recommends \
5+
nodejs

ports/_common/shell.dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
RUN git clone --depth 1 https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh \
2+
&& git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
3+
&& git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
4+
&& git clone --depth 1 https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions
5+
6+
# .zshrc is inlined here (single source of truth across ports). Persists command
7+
# history across rebuilds via the /commandhistory volume (see docker-compose.yaml).
8+
COPY --chown=${USERNAME}:${USERNAME} <<"EOF" /home/${USERNAME}/.zshrc
9+
export ZSH="$HOME/.oh-my-zsh"
10+
11+
ZSH_THEME="refined"
12+
13+
plugins=(
14+
git
15+
zsh-autosuggestions
16+
zsh-syntax-highlighting
17+
)
18+
19+
fpath+=("${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-completions/src")
20+
21+
source "$ZSH/oh-my-zsh.sh"
22+
23+
HISTFILE=/commandhistory/.zsh_history
24+
HISTSIZE=100000
25+
SAVEHIST=100000
26+
setopt INC_APPEND_HISTORY
27+
setopt SHARE_HISTORY
28+
setopt HIST_IGNORE_DUPS
29+
EOF

ports/_common/user.dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG USERNAME=hypnos
2+
ARG USER_UID=1000
3+
ARG USER_GID=1000
4+
RUN groupadd "${USERNAME}" --gid ${USER_GID} \
5+
&& useradd --create-home "${USERNAME}" --shell /usr/bin/zsh --uid "${USER_UID}" --gid "${USER_GID}" \
6+
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
7+
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/${USERNAME}"
8+
9+
USER ${USERNAME}
10+
WORKDIR /home/${USERNAME}

ports/dev-golang/Dockerfile.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
ARG BASE=docker.io/library/golang
22
FROM ${BASE}
33

4-
{{ template "apt" dict "SystemPython" true }}
4+
{{ template "apt.dockerfile" dict "SystemPython" true }}
55

6-
{{ template "node" . }}
6+
{{ template "node.dockerfile" . }}
77

8-
{{ template "user" . }}
8+
{{ template "user.dockerfile" . }}
99

1010
RUN mkdir -p ~/.cache/go-build
1111

12-
{{ template "shell" . }}
12+
{{ template "shell.dockerfile" . }}
1313

14-
{{ template "commandhistory" . }}
14+
{{ template "commandhistory.dockerfile" . }}
1515

1616
RUN mkdir -p /go/pkg/mod /go/bin \
1717
&& chown -R "${USERNAME}:${USERNAME}" /go

ports/dev-node/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ EOF
110110

111111
# Node developer tooling, installed globally into a per-user npm prefix so it
112112
# lands under the dev user's home (no root-owned /usr/local writes) and stays on
113-
# PATH. corepack ships with node and provides the pnpm/yarn shims.
113+
# PATH. corepack is installed explicitly (recent node images no longer bundle it)
114+
# and provides the pnpm/yarn shims.
114115
ENV NPM_CONFIG_PREFIX=/home/${USERNAME}/.local
115116
ENV PATH=/home/${USERNAME}/.local/bin:${PATH}
116117
RUN npm install -g \
118+
corepack \
117119
typescript \
118120
ts-node \
119-
eslint \
120-
prettier \
121121
npm-check-updates \
122122
&& corepack enable --install-directory /home/${USERNAME}/.local/bin
123123

ports/dev-node/Dockerfile.tmpl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
ARG BASE=docker.io/library/node
22
FROM ${BASE}
33

4-
{{ template "apt" dict "SystemPython" true }}
4+
{{ template "apt.dockerfile" dict "SystemPython" true }}
55

66
# The official node image ships a `node` user at UID/GID 1000, which collides
77
# with the dev user the shared "user" partial creates at 1000:1000. Remove it
88
# (and its home) so that partial can claim those IDs.
99
RUN userdel --remove node 2>/dev/null || true \
1010
&& groupdel node 2>/dev/null || true
1111

12-
{{ template "user" . }}
12+
{{ template "user.dockerfile" . }}
1313

14-
{{ template "shell" . }}
14+
{{ template "shell.dockerfile" . }}
1515

1616
# Node developer tooling, installed globally into a per-user npm prefix so it
1717
# lands under the dev user's home (no root-owned /usr/local writes) and stays on
18-
# PATH. corepack ships with node and provides the pnpm/yarn shims.
18+
# PATH. corepack is installed explicitly (recent node images no longer bundle it)
19+
# and provides the pnpm/yarn shims.
1920
ENV NPM_CONFIG_PREFIX=/home/${USERNAME}/.local
2021
ENV PATH=/home/${USERNAME}/.local/bin:${PATH}
2122
RUN npm install -g \
23+
corepack \
2224
typescript \
2325
ts-node \
2426
npm-check-updates \
2527
&& corepack enable --install-directory /home/${USERNAME}/.local/bin
2628

27-
{{ template "commandhistory" . }}
29+
{{ template "commandhistory.dockerfile" . }}

0 commit comments

Comments
 (0)