File size: 3,956 Bytes
d8148a1
6b5ef30
 
 
d8148a1
 
 
 
6b5ef30
d8148a1
 
6b5ef30
 
 
 
d8148a1
 
 
 
6b5ef30
 
d8148a1
 
 
 
 
 
 
 
 
 
6b5ef30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8148a1
 
 
 
 
 
 
 
 
 
6b5ef30
d8148a1
 
 
 
 
 
 
6b5ef30
 
 
 
 
d8148a1
 
 
 
6b5ef30
 
 
 
 
 
d8148a1
 
 
 
 
 
 
 
6b5ef30
d8148a1
6b5ef30
d8148a1
6b5ef30
 
 
 
d8148a1
6b5ef30
 
 
 
 
 
 
 
d8148a1
 
6b5ef30
d8148a1
6b5ef30
d8148a1
 
6b5ef30
d8148a1
6b5ef30
 
 
 
d8148a1
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# ===============================
# Base: Ubuntu 22.04
# code-server + Go + Node.js + PHP + Python
# XFCE + TigerVNC + noVNC
# ===============================
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

ENV NVM_DIR=/usr/local/nvm
ENV NODE_VERSION=22

ENV GO_VERSION=1.23.2

ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:/usr/local/go/bin:$PATH

# -------------------------------
# Create coder user (passwordless sudo)
# -------------------------------
USER root

RUN apt-get update && apt-get install -y sudo \
    && useradd -m -s /bin/bash coder \
    && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

WORKDIR /home/coder

# -------------------------------
# System Dependencies
# -------------------------------
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    git \
    unzip \
    zip \
    gnupg \
    ca-certificates \
    software-properties-common \
    build-essential \
    python3 \
    python3-pip \
    python3-venv \
    php \
    php-cli \
    php-mbstring \
    php-xml \
    php-curl \
    php-zip \
    php-gd \
    php-bcmath \
    php-intl \
    redis-tools \
    openjdk-17-jdk \
    clang \
    cmake \
    ninja-build \
    pkg-config \
    \
    # XFCE Desktop
    xfce4 \
    xfce4-goodies \
    \
    # VNC + noVNC
    tigervnc-standalone-server \
    novnc \
    websockify \
    \
    # Node.js / npm
    nodejs \
    npm \
    \
    && rm -rf /var/lib/apt/lists/*

# -------------------------------
# Install Go
# -------------------------------
RUN curl -LO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
    && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
    && rm go${GO_VERSION}.linux-amd64.tar.gz

# -------------------------------
# Install NVM + Node 22 + Yarn + pnpm
# -------------------------------
RUN mkdir -p $NVM_DIR \
    && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
    && . $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
    && nvm use $NODE_VERSION \
    && npm install -g yarn pnpm \
    && ln -sf $NVM_DIR/versions/node/v$NODE_VERSION/bin/node /usr/local/bin/node \
    && ln -sf $NVM_DIR/versions/node/v$NODE_VERSION/bin/npm /usr/local/bin/npm \
    && ln -sf $NVM_DIR/versions/node/v$NODE_VERSION/bin/npx /usr/local/bin/npx \
    && ln -sf $NVM_DIR/versions/node/v$NODE_VERSION/bin/yarn /usr/local/bin/yarn \
    && ln -sf $NVM_DIR/versions/node/v$NODE_VERSION/bin/pnpm /usr/local/bin/pnpm

# -------------------------------
# Install ngrok
# -------------------------------
RUN curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
        | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
    && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
        | tee /etc/apt/sources.list.d/ngrok.list \
    && apt-get update \
    && apt-get install -y ngrok \
    && rm -rf /var/lib/apt/lists/*

# -------------------------------
# Install code-server
# -------------------------------
RUN curl -fsSL https://code-server.dev/install.sh | sh

# -------------------------------
# XFCE + VNC configuration
# -------------------------------
USER coder

RUN mkdir -p /home/coder/.vnc \
    /home/coder/.config \
    /home/coder/.local/share/code-server \
    /home/coder/workspace

# VNC startup script
RUN printf '%s\n' \
    '#!/bin/sh' \
    'unset SESSION_MANAGER' \
    'unset DBUS_SESSION_BUS_ADDRESS' \
    'startxfce4 &' \
    > /home/coder/.vnc/xstartup \
    && chmod +x /home/coder/.vnc/xstartup

# -------------------------------
# Workspace
# -------------------------------
WORKDIR /home/coder/workspace

# -------------------------------
# Ports
# -------------------------------
# 7860 = code-server
# 5901 = VNC
# 6080 = noVNC
EXPOSE 7860 5901 6080

# -------------------------------
# Start code-server
# -------------------------------
CMD ["bash", "-c", "code-server --bind-addr 0.0.0.0:7860 --auth password --user-data-dir /home/coder/.local/share/code-server"]