Skip to content

Commit ae91cdc

Browse files
committed
Optimize Dockerfile: consolidate apt updates, add --no-install-recommends, clean caches
- Consolidate 3 apt-get update calls into 1 by adding all repos first - Use apt-get instead of apt for non-interactive usage - Add --no-install-recommends to all package installs - Use dpkg --print-architecture for multi-arch Go download - Clean npm/root caches and duplicate binaries in cleanup step - Remove htop and python3-dev (not needed at runtime) - Remove software-properties-common after PPA setup
1 parent 6037626 commit ae91cdc

File tree

1 file changed

+55
-28
lines changed

1 file changed

+55
-28
lines changed

fx/Dockerfile

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,59 @@ FROM codercom/enterprise-base:ubuntu
33
ENV DENO_INSTALL=/usr/local
44
ENV BUN_INSTALL=/usr/local
55
ENV NODE_VERSION=22
6+
ENV GO_VERSION=1.24.2
7+
ENV GOROOT=/usr/local/go
8+
ENV GOPATH=/home/coder/go
9+
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
610

711
USER root
812

9-
RUN apt update && apt dist-upgrade -y && \
10-
mkdir -p -m 755 /etc/apt/keyrings && \
11-
apt install -y curl git wget htop jq && \
12-
# NODE ######################################################################
13+
RUN \
14+
# REPOS ####################################################################
15+
# Add all package repos first, then do a single apt-get update
16+
apt-get update && \
17+
apt-get install -y --no-install-recommends curl wget software-properties-common gpg && \
18+
# Node repo
1319
curl -fsSL "https://deb.nodesource.com/setup_${NODE_VERSION}.x" | bash - && \
14-
apt install -y nodejs && \
15-
# PHP #######################################################################
20+
# PHP repo
1621
add-apt-repository -y ppa:ondrej/php && \
17-
apt update -y && \
18-
apt install -y --no-install-recommends \
22+
# GitHub CLI repo
23+
wget -qO /tmp/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg && \
24+
mkdir -p -m 755 /etc/apt/keyrings && \
25+
install -D -m 644 /tmp/githubcli-archive-keyring.gpg /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
26+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list && \
27+
rm -f /tmp/githubcli-archive-keyring.gpg && \
28+
# SINGLE UPDATE + INSTALL ##################################################
29+
apt-get update && \
30+
apt-get dist-upgrade -y && \
31+
apt-get install -y --no-install-recommends \
32+
git jq \
33+
# Node
34+
nodejs \
35+
# PHP
1936
php8.5-cli php8.5-common php8.5-curl php8.5-gd php8.5-imap php8.5-intl \
2037
php8.5-mailparse php8.5-mbstring php8.5-mysql php8.5-pgsql php8.5-phpdbg \
2138
php8.5-readline php8.5-redis php8.5-soap php8.5-sqlite3 php8.5-xml \
22-
php8.5-zip php8.5-bcmath php8.5-apcu php8.5-imagick && \
39+
php8.5-zip php8.5-bcmath php8.5-apcu php8.5-imagick \
40+
# Python
41+
python3 python3-pip python3-venv \
42+
# GitHub CLI
43+
gh \
44+
# Chrome libs (agent-browser)
45+
libnspr4 libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libatspi2.0-0 \
46+
libcups2t64 libxshmfence1 libgbm1 libpango-1.0-0 libpangocairo-1.0-0 \
47+
libasound2t64 libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
48+
libxi6 libgtk-3-0t64 libcairo2 libcairo-gobject2 libgdk-pixbuf-2.0-0 \
49+
libatk1.0-0 libxrender1 libfontconfig1 libdbus-1-3 libxcb1 libxext6 libx11-6 && \
2350
echo 'variables_order = "EGPCS"' > /etc/php/8.5/cli/conf.d/99-coder.ini && \
51+
# GOLANG ####################################################################
52+
ARCH=$(dpkg --print-architecture) && \
53+
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz" -o /tmp/go.tar.gz && \
54+
tar -C /usr/local -xzf /tmp/go.tar.gz && \
55+
rm /tmp/go.tar.gz && \
56+
mkdir -p /home/coder/go && \
2457
# COMPOSER ##################################################################
2558
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
26-
# GITHUB CLI ################################################################
27-
wget -qO /tmp/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg && \
28-
install -D -m 644 /tmp/githubcli-archive-keyring.gpg /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
29-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list && \
30-
apt update -y && \
31-
apt install -y --no-install-recommends gh && \
3259
# DENO ######################################################################
3360
curl -fsSL https://deno.land/install.sh | sh && \
3461
# BUN #######################################################################
@@ -48,30 +75,30 @@ RUN apt update && apt dist-upgrade -y && \
4875
ln -sf /home/coder/.opencode/bin/opencode /usr/local/bin/opencode && \
4976
# NPM: CODEX, COPILOT #######################################################
5077
npm install -g @openai/codex @github/copilot && \
51-
# CHROME LIBS (AGENT-BROWSER) ###############################################
52-
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
53-
libnspr4 libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libatspi2.0-0 \
54-
libcups2t64 libxshmfence1 libgbm1 libpango-1.0-0 libpangocairo-1.0-0 \
55-
libasound2t64 libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
56-
libxi6 libgtk-3-0t64 libcairo2 libcairo-gobject2 libgdk-pixbuf-2.0-0 \
57-
libatk1.0-0 libxrender1 libfontconfig1 libdbus-1-3 libxcb1 libxext6 libx11-6 && \
78+
# AGENT-BROWSER ##############################################################
5879
npm install -g agent-browser && \
5980
runuser -u coder -- agent-browser install && \
6081
# PROFILE (DENO, BUN PATH) ##################################################
6182
echo '' >> /etc/profile && \
83+
echo '# Go' >> /etc/profile && \
84+
echo 'export GOROOT=/usr/local/go' >> /etc/profile && \
85+
echo 'export GOPATH="$HOME/go"' >> /etc/profile && \
86+
echo 'export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"' >> /etc/profile && \
87+
echo '' >> /etc/profile && \
6288
echo '# Deno, Bun' >> /etc/profile && \
6389
echo 'export DENO_INSTALL="${DENO_INSTALL:-/usr/local}"' >> /etc/profile && \
6490
echo 'export BUN_INSTALL="${BUN_INSTALL:-/usr/local}"' >> /etc/profile && \
6591
echo '[ -d "$DENO_INSTALL/bin" ] && export PATH="$DENO_INSTALL/bin:$PATH"' >> /etc/profile && \
6692
echo '[ -d "$BUN_INSTALL/bin" ] && export PATH="$BUN_INSTALL/bin:$PATH"' >> /etc/profile && \
6793
# OWNERSHIP (coder can upgrade tools) ######################################
68-
chown -R coder:coder /home/coder/.local /home/coder/.opencode 2>/dev/null || true && \
94+
chown -R coder:coder /home/coder/.local /home/coder/.opencode /home/coder/go 2>/dev/null || true && \
6995
# CLEANUP ###################################################################
70-
apt clean -y && \
71-
apt autoclean -y && \
72-
apt remove -y wget && \
73-
apt autoremove -y && \
74-
rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
96+
apt-get clean -y && \
97+
apt-get autoclean -y && \
98+
apt-get remove -y wget software-properties-common && \
99+
apt-get autoremove -y && \
100+
rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/* \
101+
/root/.npm /root/.cache /root/.local /root/.opencode /root/.bun
75102

76103
WORKDIR /home/coder
77104

0 commit comments

Comments
 (0)