Skip to content

Commit 7025164

Browse files
committed
Tailscale for codespaces
1 parent 3ab4c1c commit 7025164

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.devcontainer/.codespace.Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
2+
# Use of this source code is governed by a BSD-style
3+
# license that can be found in the LICENSE file.
4+
5+
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux as builder
6+
USER root
7+
8+
# Magic DNS in a container where /etc/resolv.conf is a bind mount needed
9+
# extra support, currently on a development branch.
10+
WORKDIR /go/src/tailscale
11+
COPY . ./
12+
RUN git clone https://github.com/tailscale/tailscale.git && cd tailscale && \
13+
go mod download && \
14+
go install -mod=readonly ./cmd/tailscaled ./cmd/tailscale
15+
COPY . ./
16+
17+
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux
18+
USER root
19+
20+
RUN apt-get update && apt-get install -y curl gpg dnsutils
21+
COPY tailscaled /etc/init.d
22+
COPY --from=builder /go/bin/tailscaled /usr/sbin/tailscaled
23+
COPY --from=builder /go/bin/tailscale /usr/bin/tailscale
24+
25+
RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Tailscale-enabled Codespace",
3+
"dockerFile": ".codespace.Dockerfile",
4+
"context": "..",
5+
"runArgs": [
6+
"--cap-add=NET_ADMIN",
7+
"--cap-add=NET_RAW",
8+
"--device=/dev/net/tun"
9+
],
10+
"postStartCommand": "/etc/init.d/tailscaled start",
11+
}

tailscaled.service

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/sh
2-
# Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
3-
# Use of this source code is governed by a BSD-style
4-
# license that can be found in the LICENSE file.
52

63
### BEGIN INIT INFO
74
# Provides: tailscaled
@@ -32,10 +29,10 @@ export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
3229
case "$1" in
3330
start)
3431
log_daemon_msg "Starting Tailscale VPN" "tailscaled" || true
35-
if start-stop-daemon --start --quiet --oknodo --pidfile /run/tailscaled.pid --background \
36-
--exec sudo /usr/sbin/tailscaled -- --state=/var/lib/tailscale/tailscaled.state \
32+
if start-stop-daemon --start --quiet --oknodo --chuid 0:0 --pidfile /run/tailscaled.pid --background \
33+
--exec /usr/sbin/tailscaled -- --state=/var/lib/tailscale/tailscaled.state \
3734
--socket=/run/tailscale/tailscaled.sock --port 41641; then
38-
sudo -E tailscale up --hostname=gitpod --authkey=${TAILSCALE_AUTHKEY} --netfilter-mode=off
35+
tailscale up --authkey=${TAILSCALE_AUTHKEY} --netfilter-mode=off
3936
log_end_msg 0 || true
4037
else
4138
log_end_msg 1 || true

0 commit comments

Comments
 (0)