Skip to content

Commit 7f1b778

Browse files
committed
add code-server - this is a WIP container, its fully functional, but please see README
0 parents  commit 7f1b778

13 files changed

Lines changed: 633 additions & 0 deletions

File tree

.daemonless/config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build:
2+
architectures:
3+
- amd64
4+
variants:
5+
- tag: latest
6+
aliases: []
7+
8+
cit:
9+
mode: screenshot
10+
port: 8080
11+
health: /healthz

.github/workflows/build.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build FreeBSD container image with dbuild.
2+
# Docs: https://github.com/daemonless/dbuild
3+
4+
name: Daemonless Build FreeBSD Container
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths-ignore: ['*.md', 'LICENSE', '.gitignore']
10+
pull_request:
11+
branches: [main]
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
uses: daemonless/dbuild/.github/workflows/build.yml@v2
17+
permissions:
18+
contents: read
19+
packages: write
20+
secrets: inherit

Containerfile

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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

Containerfile.j2

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

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2025, daemonless contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)