1+ # --------------------------------------------------------------------------
2+ # THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
3+ #
4+ # Source: Containerfile.j2
5+ # --------------------------------------------------------------------------
6+
7+ ARG BASE_VERSION=15
8+ FROM ghcr.io/daemonless/base:${BASE_VERSION} AS builder
9+
10+ ARG APP_VERSION=""
11+ ARG UPSTREAM_URL="https://registry.npmjs.org/code-server/latest"
12+ ARG UPSTREAM_JQ=".version"
13+
14+ # Build dependencies per https://github.com/coder/code-server/blob/main/docs/npm.md#freebsd
15+ # libinotify: userland inotify for @parcel/watcher file watching
16+ # node-pty: FreeBSD support merged upstream
17+ RUN pkg update && \
18+ pkg install -y \
19+ FreeBSD-clang \
20+ FreeBSD-toolchain \
21+ FreeBSD-clibs-dev \
22+ FreeBSD-runtime-dev \
23+ node \
24+ npm \
25+ python3 \
26+ gmake \
27+ pkgconf \
28+ git \
29+ libinotify && \
30+ pkg clean -ay && \
31+ rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
32+
33+ # npm global install fails on FreeBSD: ENOENT when it tries to chdir into
34+ # lib/vscode/node_modules/* before those dirs exist. Workaround: extract
35+ # the package tarball manually, then run npm install in each directory.
36+
37+ RUN APP_VERSION=${APP_VERSION:-$(fetch -qo - "${UPSTREAM_URL}" | jq -r "${UPSTREAM_JQ}" )} && \
38+ fetch -qo /tmp/code-server.tgz \
39+ "https://registry.npmjs.org/code-server/-/code-server-${APP_VERSION}.tgz" && \
40+ mkdir -p /usr/local/lib/node_modules/code-server && \
41+ tar -xzf /tmp/code-server.tgz \
42+ -C /usr/local/lib/node_modules/code-server --strip-components=1 && \
43+ rm /tmp/code-server.tgz
44+
45+ WORKDIR /usr/local/lib/node_modules/code-server
46+
47+ # Remove kerberos from vscode - enterprise proxy auth only, disabled on FreeBSD
48+ RUN python3 -c 'import json; p=json.load(open("lib/vscode/package.json")); p.get("dependencies",{}).pop("kerberos",None); p.get("devDependencies",{}).pop("@types/kerberos",None); json.dump(p,open("lib/vscode/package.json","w"),indent=2); print("Patched: kerberos removed")'
49+
50+ # Install lib/vscode deps first so the dir exists when code-server root install runs
51+ # --ignore-scripts: skip vscode's full TS build; npm rebuild compiles native modules only
52+ WORKDIR /usr/local/lib/node_modules/code-server/lib/vscode
53+ RUN npm install --unsafe-perm --omit=dev --ignore-scripts --no-audit --no-fund
54+
55+ # FreeBSD compatibility patches — see patches/ for details
56+ COPY patches/ /tmp/patches/
57+ RUN patch -p1 < /tmp/patches/node-pty.patch && \
58+ node /tmp/patches/ptyhost.js && \
59+ node /tmp/patches/deviceid.js && \
60+ node /tmp/patches/platform.js
61+
62+ RUN npm rebuild node-pty @vscode/spdlog @parcel/watcher @vscode/native-watchdog
63+
64+ # Install code-server root deps + run postinstall (compiles argon2, node-pty etc.)
65+ WORKDIR /usr/local/lib/node_modules/code-server
66+ RUN npm install --unsafe-perm --omit=dev --no-audit --no-fund
67+
68+ # Create global symlink and record version
69+ RUN APP_VERSION=${APP_VERSION:-$(fetch -qo - "${UPSTREAM_URL}" | jq -r "${UPSTREAM_JQ}" )} && \
70+ ln -sf /usr/local/lib/node_modules/code-server/out/node/entry.js /usr/local/bin/code-server && \
71+ mkdir -p /app && echo "${APP_VERSION}" > /app/version && \
72+ npm cache clean --force
73+
74+ # Production image
75+ FROM ghcr.io/daemonless/base:${BASE_VERSION}
76+
77+ ARG FREEBSD_ARCH=amd64
78+ ARG APP_VERSION=""
79+ ARG UPSTREAM_URL="https://registry.npmjs.org/code-server/latest"
80+ ARG UPSTREAM_JQ=".version"
81+ ARG PACKAGES="node npm ca_root_nss libinotify doas python3 gmake gcc llvm FreeBSD-clang FreeBSD-toolchain"
82+
83+ LABEL org.opencontainers.image.title="code-server" \
84+ org.opencontainers.image.description="code-server on FreeBSD." \
85+ org.opencontainers.image.source="https://github.com/daemonless/code-server" \
86+ org.opencontainers.image.url="https://coder.com/docs/code-server" \
87+ org.opencontainers.image.licenses="MIT" \
88+ org.opencontainers.image.vendor="daemonless" \
89+ org.opencontainers.image.authors="daemonless" \
90+ io.daemonless.category="Development" \
91+ io.daemonless.port="8080" \
92+ io.daemonless.arch="${FREEBSD_ARCH}" \
93+ io.daemonless.pkg-source="binary" \
94+ io.daemonless.upstream-url="${UPSTREAM_URL}" \
95+ io.daemonless.upstream-jq="${UPSTREAM_JQ}" \
96+ io.daemonless.packages="${PACKAGES}" \
97+ io.daemonless.wip="true"
98+
99+ # Runtime: node + dev tools
100+ RUN pkg update && \
101+ pkg install -y ${PACKAGES} && \
102+ pkg clean -ay && \
103+ rm -rf /var/cache/pkg/* /var/db/pkg/repos/* && \
104+ chmod 4755 /usr/local/bin/doas && \
105+ echo "permit nopass keepenv bsd" > /usr/local/etc/doas.conf && \
106+ chmod 0400 /usr/local/etc/doas.conf
107+
108+ # Copy code-server from builder
109+ COPY --from=builder /app/version /app/version
110+ COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
111+ RUN ln -sf /usr/local/lib/node_modules/code-server/out/node/entry.js /usr/local/bin/code-server && \
112+ chmod -R o+rX /usr/local/lib/node_modules
113+
114+ # Copy root filesystem
115+ COPY root/ /
116+
117+ # Set permissions
118+ RUN chmod +x /etc/services.d/code-server/run /healthz
119+
120+ ENV HOME="/config"
121+
122+ # Workspace dir (matches linuxserver convention)
123+ RUN mkdir -p /config/workspace && \
124+ chown -R bsd:bsd /config
125+
126+ # Expose
127+ EXPOSE 8080
128+
129+ # Volumes
130+ VOLUME /config
0 commit comments