Skip to content

Commit 4565216

Browse files
committed
building from source
1 parent 7bead65 commit 4565216

2 files changed

Lines changed: 79 additions & 5 deletions

File tree

.dockerignore

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# Exclude everything by default
12
**
3+
4+
# Include necessary files for building
5+
!package.json
6+
!package-lock.json
7+
!tsconfig.json
8+
!src/
9+
!lib/
10+
!patches/
11+
!ci/
212
!release-packages
3-
!ci
13+
!.git/
14+
!.gitmodules
15+
!eslint.config.mjs
16+
!.prettierrc.yaml
17+
!.prettierignore
18+
!.editorconfig
19+
!.node-version
20+
!.nvmrc
21+
!test/

ci/release-image/Dockerfile

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
# syntax=docker/dockerfile:experimental
2-
32
ARG 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+
# ==============================================================================
452
FROM 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+
# ==============================================================================
762
FROM $BASE
863

964
RUN apt-get update \
@@ -45,7 +100,8 @@ RUN ARCH="$(dpkg --print-architecture)" \
45100
&& printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
46101

47102
COPY 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
58114
USER 1000
59115
ENV USER=coder
60116
WORKDIR /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

Comments
 (0)