Skip to content

Commit 4052478

Browse files
committed
Add Gitpod, Codespaces config
1 parent aa82ea1 commit 4052478

File tree

5 files changed

+250
-5
lines changed

5 files changed

+250
-5
lines changed

.devcontainer/Dockerfile

+25
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

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

.gitpod.Dockerfile

+25
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 gitpod/workspace-full:latest
6+
7+
USER root
8+
9+
RUN curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.gpg | sudo apt-key add - \
10+
&& curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.list | sudo tee /etc/apt/sources.list.d/tailscale.list \
11+
&& apt-get update \
12+
&& apt-get install -y tailscale
13+
14+
USER gitpod
15+
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
16+
ENV SHELL=zsh
17+
RUN echo "alias gits='git status'" >> $HOME/.zshrc
18+
RUN echo "alias ls='ls -GFh'" >> $HOME/.zshrc
19+
ENV NVM_DIR="$HOME/.nvm"
20+
RUN echo ". ~/.nvm/nvm.sh" >> $HOME/.zshrc
21+
RUN sed -i 's/plugins=(git)/plugins=(git npm docker-compose docker)/' $HOME/.zshrc
22+
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
23+
RUN sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' $HOME/.zshrc
24+
RUN wget https://gist.githubusercontent.com/nooobcoder/d8f728b999329c4edf563cd378d0398c/raw/.p10k.zsh -O $HOME/.p10k.zsh
25+
RUN echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> $HOME/.zshrc

.gitpod.yml

+134-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,134 @@
1-
tasks:
2-
- before: >
3-
[[ ! -z $GNUPG_KEY ]] &&
4-
gpg --verbose --batch --import <(echo $GNUPG_KEY|base64 -d) &&
5-
echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf
1+
image:
2+
file: .gitpod.Dockerfile
3+
tasks:
4+
- name: tailscaled
5+
command: |
6+
if [ -n "${TS_STATE_TAILSCALE_EXAMPLE}" ]; then
7+
# restore the tailscale state from gitpod user's env vars
8+
sudo mkdir -p /var/lib/tailscale
9+
echo "${TS_STATE_TAILSCALE_EXAMPLE}" | sudo tee /var/lib/tailscale/tailscaled.state > /dev/null
10+
fi
11+
sudo tailscaled
12+
- name: Tailscale
13+
command: |
14+
sudo -E tailscale up --hostname "gitpod@nooobcoder-${GITPOD_WORKSPACE_ID}" \
15+
--authkey "${TAILSCALE_AUTHKEY}"
16+
- name: ImportGPG
17+
command: >
18+
[[ ! -z $GNUPG_KEY ]] &&
19+
gpg --verbose --batch --import <(echo $GNUPG_KEY|base64 -d) &&
20+
echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf &&
21+
git config commit.gpgsign true
22+
vscode:
23+
extensions:
24+
- mutantdino.resourcemonitor
25+
- cweijan.vscode-mysql-client2
26+
- Gruntfuggly.todo-tree
27+
- jsDelivr.jsdelivr
28+
- manuth.eslint-language-service
29+
- markwylde.vscode-filesize
30+
- mongodb.mongodb-vscode
31+
- monokai.theme-monokai-pro-vscode
32+
- ngryman.codesandbox-theme
33+
- njzy.stats-bar
34+
- pflannery.vscode-versionlens
35+
- rangav.vscode-thunder-client
36+
- redwan-hossain.auto-rename-tag-clone
37+
- tombonnike.vscode-status-bar-format-toggle
38+
- vlanguage.vscode-vlang
39+
- vscjava.vscode-spring-initializr
40+
- zaaack.markdown-editor
41+
- aaron-bond.better-comments
42+
- ahmadawais.shades-of-purple
43+
- apollographql.vscode-apollo
44+
- avraammavridis.vsc-react-documentation
45+
- bengreenier.vscode-node-readme
46+
- benjaminbenais.codesandbox-dark
47+
- bierner.color-info
48+
- bradlc.vscode-tailwindcss
49+
- bungcip.better-toml
50+
- chris-noring.node-snippets
51+
- christian-kohler.npm-intellisense
52+
- christian-kohler.path-intellisense
53+
- chrmarti.regex
54+
- CodeSandbox-io.codesandbox-projects
55+
- CodeSandbox-io.codesandbox-projects-theme
56+
- cssho.vscode-svgviewer
57+
- DaltonMenezes.aura-theme
58+
- Dart-Code.dart-code
59+
- Dart-Code.flutter
60+
- dbaeumer.vscode-eslint
61+
- docsmsft.docs-markdown
62+
- docsmsft.docs-preview
63+
- DominicVonk.parameter-hints
64+
- dsznajder.es7-react-js-snippets
65+
- eamodio.gitlens
66+
- ecmel.vscode-html-css
67+
- EditorConfig.EditorConfig
68+
- eg2.vscode-npm-script
69+
- esbenp.prettier-vscode
70+
- evan-buss.font-switcher
71+
- formulahendry.auto-rename-tag
72+
- geeebe.duplicate
73+
- GitHub.codespaces
74+
- GitHub.copilot-labs
75+
- GitHub.copilot-nightly
76+
- GitHub.github-vscode-theme
77+
- GitHub.vscode-pull-request-github
78+
- gitpod.gitpod-desktop
79+
- golang.go
80+
- GraphQL.vscode-graphql
81+
- hashicorp.terraform
82+
- hollowtree.vue-snippets
83+
- jcbuisson.vue
84+
- jeff-hykin.better-cpp-syntax
85+
- k--kato.intellij-idea-keybindings
86+
- me-dutour-mathieu.vscode-github-actions
87+
- mechatroner.rainbow-csv
88+
- mikestead.dotenv
89+
- ms-python.python
90+
- ms-python.vscode-pylance
91+
- ms-toolsai.jupyter
92+
- ms-toolsai.jupyter-keymap
93+
- ms-vscode-remote.remote-containers
94+
- ms-vscode-remote.remote-ssh
95+
- ms-vscode-remote.remote-ssh-edit
96+
- ms-vscode-remote.remote-wsl
97+
- ms-vscode-remote.vscode-remote-extensionpack
98+
- ms-vscode.cmake-tools
99+
- ms-vscode.cpptools
100+
- ms-vscode.cpptools-extension-pack
101+
- ms-vscode.cpptools-themes
102+
- ms-vscode.js-debug-nightly
103+
- ms-vscode.vscode-typescript-next
104+
- ms-vscode.vscode-typescript-tslint-plugin
105+
- ms-vsliveshare.vsliveshare
106+
- ms-vsliveshare.vsliveshare-audio
107+
- ms-vsliveshare.vsliveshare-pack
108+
- naumovs.color-highlight
109+
- oderwat.indent-rainbow
110+
- PKief.material-icon-theme
111+
- pranaygp.vscode-css-peek
112+
- Prisma.prisma
113+
- Prisma.prisma-insider
114+
- redhat.java
115+
- redhat.vscode-xml
116+
- redhat.vscode-yaml
117+
- ritwickdey.LiveServer
118+
- sdras.night-owl
119+
- silvenon.mdx
120+
- steoates.autoimport
121+
- tgreen7.vs-code-node-require
122+
- tomoki1207.selectline-statusbar
123+
- twxs.cmake
124+
- usernamehw.errorlens
125+
- VisualStudioExptTeam.vscodeintellicode
126+
- vscjava.vscode-java-debug
127+
- vscjava.vscode-java-dependency
128+
- vscjava.vscode-java-pack
129+
- vscjava.vscode-java-test
130+
- vscjava.vscode-maven
131+
- vscode-icons-team.vscode-icons
132+
- wix.vscode-import-cost
133+
- xabikos.JavaScriptSnippets
134+
- Zignd.html-css-class-completion

tailscaled

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
### BEGIN INIT INFO
4+
# Provides: tailscaled
5+
# Required-Start:
6+
# Required-Stop:
7+
# Default-Start:
8+
# Default-Stop:
9+
# Short-Description: Tailscale Mesh Wireguard VPN
10+
### END INIT INFO
11+
12+
set -e
13+
14+
# /etc/init.d/tailscale: start and stop the Tailscale VPN service
15+
16+
test -x /usr/sbin/tailscaled || exit 0
17+
18+
umask 022
19+
20+
. /lib/lsb/init-functions
21+
22+
# Are we running from init?
23+
run_by_init() {
24+
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
25+
}
26+
27+
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
28+
29+
case "$1" in
30+
start)
31+
log_daemon_msg "Starting Tailscale VPN" "tailscaled" || true
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 \
34+
--socket=/run/tailscale/tailscaled.sock --port 41641; then
35+
tailscale up --authkey=${TAILSCALE_AUTHKEY} --netfilter-mode=off
36+
log_end_msg 0 || true
37+
else
38+
log_end_msg 1 || true
39+
fi
40+
;;
41+
stop)
42+
log_daemon_msg "Stopping Tailscale VPN" "tailscaled" || true
43+
if start-stop-daemon --stop --quiet --oknodo --pidfile /run/tailscaled.pid --exec /usr/sbin/tailscaled; then
44+
log_end_msg 0 || true
45+
else
46+
log_end_msg 1 || true
47+
fi
48+
;;
49+
50+
status)
51+
status_of_proc -p /run/tailscaled.pid /usr/sbin/tailscaled tailscaled && exit 0 || exit $?
52+
;;
53+
54+
*)
55+
log_action_msg "Usage: /etc/init.d/tailscaled {start|stop|status}" || true
56+
exit 1
57+
esac
58+
59+
exit 0

0 commit comments

Comments
 (0)