-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
190 lines (154 loc) · 8.96 KB
/
Copy pathDockerfile
File metadata and controls
190 lines (154 loc) · 8.96 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# ╔══════════════════════════════════════════════════════════════════╗
# ║ mosgarage/code-server · Dockerfile ║
# ║ ║
# ║ Variants (--target): ║
# ║ base Ubuntu 22.04 + code-server + Node 20 + .NET runtime ║
# ║ sdk base + .NET 8 SDK (for local dev / CI) ║
# ║ python base + Python 3.12 + uv ║
# ║ full base + SDK + Python (everything) ║
# ║ ║
# ║ :base + :latest → docker.io/mosgarage/code-server ║
# ║ :full → docker.io/mosgarage/workspace ║
# ║ ║
# ║ WSL distro: make wsl-pack TARGET=full ║
# ╚══════════════════════════════════════════════════════════════════╝
ARG UBUNTU_VERSION=22.04
ARG NODE_VERSION=20
ARG DOTNET_CHANNEL=8.0
# ── base ──────────────────────────────────────────────────────────────────────
# Mirrors the workspace-base stage from mosgarage/mosgarage Dockerfile
# so mosgarage/code-server:latest and mosgarage/workspace:latest stay in sync.
FROM ubuntu:${UBUNTU_VERSION} AS base
ARG NODE_VERSION
ARG DOTNET_CHANNEL
ENV DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
DOTNET_ROOT=/usr/local/dotnet \
PATH="$PATH:/usr/local/dotnet"
LABEL org.opencontainers.image.title="mosgarage/code-server"
LABEL org.opencontainers.image.description="mosgarage managed workspace — code-server + Node + .NET runtime"
LABEL org.opencontainers.image.source="https://github.com/mosgarage/code-server"
LABEL org.opencontainers.image.vendor="mosgarage"
# ── System packages (exact match to workspace-base) ───────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
git \
openssh-client \
openssh-server \
ca-certificates \
build-essential \
python3 \
python3-pip \
unzip \
zip \
jq \
vim \
nano \
htop \
supervisor \
inotify-tools \
net-tools \
locales \
sudo \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
# ── Node.js 20 LTS ────────────────────────────────────────────────────────────
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest pm2 \
&& rm -rf /var/lib/apt/lists/*
# ── code-server ───────────────────────────────────────────────────────────────
RUN curl -fsSL https://code-server.dev/install.sh | sh \
&& rm -rf /tmp/code-server*
# ── .NET aspnetcore runtime (mirrors workspace-base, no SDK overhead) ─────────
RUN curl -fsSL https://dot.net/v1/dotnet-install.sh \
| bash -s -- --runtime aspnetcore --channel ${DOTNET_CHANNEL} \
--install-dir /usr/local/dotnet \
&& /usr/local/dotnet/dotnet --info
# ── mosgarage user ────────────────────────────────────────────────────────────
RUN useradd -m -s /bin/bash -d /home/mosgarage mosgarage \
&& echo "mosgarage ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/mosgarage \
&& chmod 0440 /etc/sudoers.d/mosgarage
# ── Workspace directory structure ─────────────────────────────────────────────
RUN mkdir -p \
/home/mosgarage/.config/code-server \
/home/mosgarage/.ssh \
/home/mosgarage/workspace \
/home/mosgarage/web \
/app/agent \
/var/log/mosgarage \
&& chown -R mosgarage:mosgarage /home/mosgarage /var/log/mosgarage
# ── SSH hardening ─────────────────────────────────────────────────────────────
RUN mkdir -p /run/sshd && ssh-keygen -A \
&& sed -i \
-e 's/#PasswordAuthentication yes/PasswordAuthentication no/' \
-e 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' \
/etc/ssh/sshd_config \
&& echo "AllowUsers mosgarage" >> /etc/ssh/sshd_config \
&& echo "Port 2222" >> /etc/ssh/sshd_config
# ── Configs ───────────────────────────────────────────────────────────────────
COPY config/workspace-supervisord.conf /etc/supervisor/conf.d/workspace.conf
COPY config/code-server.yaml /home/mosgarage/.config/code-server/config.yaml
COPY config/wsl.conf /etc/wsl.conf
# ── Scripts ───────────────────────────────────────────────────────────────────
COPY scripts/workspace-startup.sh /usr/local/bin/workspace-start
COPY scripts/mgw /usr/local/bin/mgw
RUN chmod +x /usr/local/bin/workspace-start /usr/local/bin/mgw
# ── Web landing page ──────────────────────────────────────────────────────────
COPY web/ /home/mosgarage/web/
# ── Ownership ─────────────────────────────────────────────────────────────────
RUN chown -R mosgarage:mosgarage \
/home/mosgarage/.config \
/home/mosgarage/web
# ── Ports ─────────────────────────────────────────────────────────────────────
# 8080 → code-server (VS Code browser IDE)
# 3000 → user app dev port
# 4000 → user app dev port
# 7072 → workspace agent (mosgarage protocol)
# 2222 → SSH
EXPOSE 8080 3000 4000 7072 2222
USER mosgarage
WORKDIR /home/mosgarage/workspace
CMD ["/usr/local/bin/workspace-start"]
# ── sdk ───────────────────────────────────────────────────────────────────────
# base + full .NET 8 SDK (replaces aspnetcore-only runtime)
FROM base AS sdk
USER root
ARG DOTNET_CHANNEL=8.0
RUN curl -fsSL https://dot.net/v1/dotnet-install.sh \
| bash -s -- --channel ${DOTNET_CHANNEL} \
--install-dir /usr/local/dotnet \
&& /usr/local/dotnet/dotnet --version
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 \
DOTNET_NOLOGO=1 \
NUGET_XMLDOC_MODE=skip
USER mosgarage
# ── python ────────────────────────────────────────────────────────────────────
# base + Python 3.12 venv + uv
FROM base AS python
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3.12-dev \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
&& pip install --no-cache-dir uv \
&& rm -rf /var/lib/apt/lists/*
USER mosgarage
# ── full ──────────────────────────────────────────────────────────────────────
# .NET SDK + Python 3.12 + uv — the "grades" top-level distro
FROM sdk AS full
USER root
ARG DOTNET_CHANNEL=8.0
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3.12-dev \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
&& pip install --no-cache-dir uv \
&& rm -rf /var/lib/apt/lists/*
USER mosgarage