11# syntax=docker/dockerfile:experimental
2-
32ARG BASE=debian:12
3+
4+ # ==============================================================================
5+ # Builder Stage
6+ # This stage builds code-server from source and creates a .deb package.
7+ # ==============================================================================
8+ FROM node:20-bookworm as builder
9+
10+ # TARGETARCH is automatically set by Docker to the architecture of the build machine (e.g., amd64, arm64)
11+ ARG TARGETARCH
12+
13+ # Install build dependencies.
14+ # nfpm is used for creating .deb packages.
15+ # We download the correct version for the target architecture.
16+ RUN apt-get update && apt-get install -y git curl rsync jq \
17+ && NFPM_ARCH=${TARGETARCH} && \
18+ if [ "${TARGETARCH}" = "amd64" ]; then NFPM_ARCH="x86_64" ; fi && \
19+ curl -sL "https://github.com/goreleaser/nfpm/releases/download/v2.35.3/nfpm_2.35.3_Linux_${NFPM_ARCH}.tar.gz" | tar -xz -C /usr/local/bin nfpm \
20+ && chmod +x /usr/local/bin/nfpm
21+
22+ WORKDIR /app
23+
24+ # Copy the entire project source. We need the .git directory for versioning.
25+ COPY . .
26+
27+ # Initialize git submodules.
28+ # Running as root in the container, so we need to mark the directory as safe.
29+ RUN git config --global --add safe.directory /app && git submodule update --init --recursive
30+
31+ # Install all dependencies.
32+ RUN npm install
33+
34+ RUN cd lib/vscode && npm install
35+
36+ # Build and package code-server.
37+ # All build scripts will now run in a Linux environment, producing the correct artifacts.
38+ ENV VERSION=0.0.1
39+ # ENV NODE_OPTIONS="--max-old-space-size=4096"
40+ RUN npm run build:vscode
41+ RUN npm run build
42+ RUN npm run release:standalone
43+ RUN npm run package
44+ # RUN ./ci/build/build-release.sh
45+ # RUN ./ci/build/build-packages.sh
46+
47+
48+ # ==============================================================================
49+ # Packages Stage
50+ # This stage simply holds the .deb file for the final image.
51+ # ==============================================================================
452FROM scratch AS packages
5- COPY release-packages/code-server*.deb /tmp/
653
54+ # Copy the .deb package from the builder stage.
55+ COPY --from=builder /app/release-packages/code-server*${TARGETARCH}*.deb /tmp/
56+
57+
58+ # ==============================================================================
59+ # Final Stage
60+ # This is the original Dockerfile, mostly unmodified.
61+ # ==============================================================================
762FROM $BASE
863
964RUN apt-get update \
@@ -45,7 +100,8 @@ RUN ARCH="$(dpkg --print-architecture)" \
45100 && printf "user: coder\n group: coder\n " > /etc/fixuid/config.yml
46101
47102COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
48- RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*$(dpkg --print-architecture).deb
103+ # The glob pattern here is simplified since we now know the exact architecture.
104+ RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*.deb
49105
50106# Allow users to have scripts run on container startup to prepare workspace.
51107# https://github.com/coder/code-server/issues/5177
@@ -58,4 +114,4 @@ EXPOSE 8080
58114USER 1000
59115ENV USER=coder
60116WORKDIR /home/coder
61- ENTRYPOINT ["/usr/bin/entrypoint.sh" , "--bind-addr" , "0.0.0.0:8080" , "." ]
117+ ENTRYPOINT ["/usr/bin/entrypoint.sh" , "--bind-addr" , "0.0.0.0:8080" , "." ]
0 commit comments