Skip to content

Enhance Docker setup for QBraid Code-Server #7369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 63 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
**
!release-packages
!ci
# Node
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# VSCode
.vscode

# Build outputs
/out
/dist
/lib/*.js
/lib/*.d.ts
/lib/*.js.map

# OS
.DS_Store
Thumbs.db

# Project specific
/test/integration/node_modules

# Logs
*.log

# Git files
.git
.gitignore

# Docs (keep essential docs)
docs/
*.md
!README.md
!QBRAID_BUILD_README.md

# Large directories we don't need
.github/
ci/
test/
patches/
.pc/
.tours/

# Development files
.eslintrc.js
.prettierrc.yaml
.editorconfig
eslint.config.mjs
tsconfig.json
package-lock.json
renovate.json
.node-version
.nvmrc
flake.nix
flake.lock

# Include our custom files
!extensions
!logo-square.png
!Dockerfile.qbraid
!build-qbraid-docker.sh
!install-qbraid-extensions.sh
43 changes: 43 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM node:20-bullseye AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
git-lfs \
python3 \
quilt \
jq \
rsync \
curl \
&& rm -rf /var/lib/apt/lists/*

# Install nfpm from GitHub releases (latest version)
RUN ARCH="$(dpkg --print-architecture)" && \
case "$ARCH" in \
"amd64") NFPM_ARCH="x86_64" ;; \
"arm64") NFPM_ARCH="aarch64" ;; \
*) NFPM_ARCH="$ARCH" ;; \
esac && \
echo "Installing nfpm for architecture: $NFPM_ARCH" && \
curl -fsSL "https://github.com/goreleaser/nfpm/releases/download/v2.42.1/nfpm_2.42.1_linux_${NFPM_ARCH}.tar.gz" | \
tar -xz -C /usr/local/bin && \
chmod +x /usr/local/bin/nfpm && \
nfpm --version

WORKDIR /src
COPY . .

# Initialize submodules and apply patches
RUN git submodule update --init && quilt push -a

# Install dependencies and build
RUN npm install && \
npm run build && \
VERSION=${TAG} npm run build:vscode && \
KEEP_MODULES=1 npm run release && \
npm run package

# Extract the packages
FROM scratch AS packages
COPY --from=builder /src/release-packages/ /packages/
54 changes: 54 additions & 0 deletions Dockerfile.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Custom Code-Server Dockerfile with QBraid branding
FROM node:20-bullseye as builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
git-lfs \
python3 \
quilt \
jq \
rsync \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /src

# Copy source code
COPY . .

# Initialize git submodules
RUN git submodule update --init

# Apply patches
RUN quilt push -a || true

# Install dependencies and build
RUN npm install && \
npm run build && \
VERSION=0.0.0 npm run build:vscode && \
npm run release

# Build packages
RUN npm run package

# Production stage
FROM codercom/code-server:latest

# Switch to root to install packages
USER root

# Copy our custom build
COPY --from=builder /src/release-packages/*.deb /tmp/

# Install our custom build
RUN dpkg -i /tmp/*.deb || apt-get update && apt-get install -f -y

# Copy custom favicon files (we'll add these in the next step)
# COPY logo-square.png /opt/code-server/lib/vscode/src/vs/workbench/browser/media/favicon.png

USER 1000

EXPOSE 8080
ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "."]
45 changes: 45 additions & 0 deletions Dockerfile.qbraid
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax=docker/dockerfile:experimental
# QBraid customized Code-Server

FROM codercom/code-server:latest

ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"

# Switch to root to make changes
USER root

# Create jovyan user and group
RUN userdel coder && \
groupadd -f -g ${NB_GID} ${NB_USER} && \
useradd -u ${NB_UID} -g ${NB_GID} -m -s /bin/bash ${NB_USER}

# Create extensions directory and copy extensions to permanent location
RUN mkdir -p /opt/qbraid-extensions
COPY ./extensions/ /opt/qbraid-extensions/

# Copy the extension installation script
COPY install-qbraid-extensions.sh /opt/install-qbraid-extensions.sh
RUN chmod +x /opt/install-qbraid-extensions.sh
# Set ownership for jovyan user
RUN chown -R ${NB_USER}:${NB_GID} /opt/qbraid-extensions

# Allow users to have scripts run on container startup to prepare workspace.
ENV ENTRYPOINTD=/home/${NB_USER}/entrypoint.d

# Disable authentication by setting empty password
ENV PASSWORD=""

# Create entrypoint.d directory and add our extension installation script
RUN mkdir -p /home/${NB_USER}/entrypoint.d && \
echo '#!/bin/bash' > /home/${NB_USER}/entrypoint.d/install-extensions.sh && \
echo '/opt/install-qbraid-extensions.sh &' >> /home/${NB_USER}/entrypoint.d/install-extensions.sh && \
chmod +x /home/${NB_USER}/entrypoint.d/install-extensions.sh && \
chown -R ${NB_USER}:${NB_GID} /home/${NB_USER}/entrypoint.d

EXPOSE 8080
USER ${NB_USER}
ENV USER=${NB_USER}
WORKDIR /home/${NB_USER}
ENTRYPOINT ["/usr/bin/entrypoint.sh", "--bind-addr", "0.0.0.0:8080", "--auth", "none", "."]
Loading