Skip to content

Commit e61bc07

Browse files
committed
initial commit
0 parents  commit e61bc07

12 files changed

Lines changed: 317 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
build-and-push-docker-image:
10+
name: Build Docker image and push
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Set up Docker Buildx
18+
id: buildx
19+
uses: docker/setup-buildx-action@v1
20+
21+
- name: Login to Github Packages
22+
uses: docker/login-action@v1
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Build image and push to GitHub Container Registry
29+
uses: docker/build-push-action@v2
30+
with:
31+
context: image/.
32+
tags: ghcr.io/edythecow/code-server:latest
33+
push: ${{ github.ref == 'refs/heads/master' }}
34+
35+
- name: Image digest
36+
run: echo ${{ steps.docker_build.outputs.digest }}

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<p align="center">
2+
<img width="400" src="https://raw.githubusercontent.com/BeefBytes/Assets/master/Other/container_illustration/v2/dockerized_vscode.png">
3+
</p>
4+
5+
# 📚 About
6+
There’s already plenty of code-server docker setups out there, what’s the point of this? Well, every single alternative I found was either focused on a specific development environment or it had too much going on, with bunch layers of stuff I was never going to use.
7+
8+
I wanted something barebones and simple, there’s no custom base images, no extra features you’ll never use. The whole image consists of a Dockerfile and entrypoint.sh, that’s it.
9+
10+
The idea behind this setup is running code-server behind Traefik reverse proxy with docker extension installed on vscode. From code-server you’ll be able to spin up any kind of container and develop without ever installing node, python or whatever else on your system.
11+
12+
# 🧰 Getting Started
13+
The guide assumes you already know basics of docker and docker compose. The reason Traefik and code-server compose files are split up, is to keep things modular in case you already run Traefik on your system.
14+
15+
## Requirements
16+
- Domain
17+
- [Docker](https://docs.docker.com/engine/install/#server)
18+
- Docker Compose (comes with Docker Engine now)
19+
20+
# 🏗️ Installation
21+
22+
### Preparations / Setting up Traefik
23+
You can skip this part in case you already have Traefik running. However, it may be still useful to look at the configuration on the repo in case you're having issues.
24+
25+
<b>Clone repository</b><br />
26+
```
27+
git clone https://github.com/EdyTheCow/docker-code-server.git
28+
```
29+
30+
<b>Set correct acme.json permissions</b><br />
31+
32+
Navigate to `_base/data/traefik/` and run
33+
```
34+
sudo chmod 600 acme.json
35+
```
36+
37+
<b>Setup basic auth</b><br />
38+
Basic auth provides extra layer of security on top of code-server authentication.
39+
Generate htpasswd and copy it to `_base/data/traefik/.htpasswd`
40+
41+
<b>Start docker compose</b><br />
42+
Inside of `_base/compose` run
43+
```
44+
docker-compose up -d
45+
```
46+
47+
### Setup code-server
48+
49+
<b>Configure variables</b><br />
50+
51+
Navigate to `code-server/compose/.env` and set these variables
52+
53+
| Variable | Description |
54+
|-|-|
55+
| DOMAIN | Domain you're going to use to access the code-server |
56+
| PASSWORD | Password for code-server |
57+
58+
<b>Configure container user</b><br />
59+
The container itself runs a non-root user you'll have to specify in `code-server/compose/docker-compose.yml`. In order to pass docker cli permissions on to container you'll have to specify your docker group ID.
60+
61+
<b>Example: `user: "1000:999"`</b><br />
62+
1000 being your user ID and 999 being your docker group ID.
63+
64+
The `DOCKER_USER=${USER}` variable is meant to take your current user's username and pass it on to the container. Meaning you'll have your username from host automatically setup inside container. You can however remove the variable from `docker-compose.yml` alltogether and it will use username `coder` instead.
65+
66+
<b>Start docker compose</b><br />
67+
```
68+
docker-compose up -d
69+
```
70+
You can now navigate to `DOMAIN` you set earlier to access code-server. You can now open terminal and continue setup of zsh and Oh My Zsh.
71+
72+
### Setup Oh My Zsh theme
73+
By default image installs zsh and Oh My Zsh with a powerlevel10k theme, so you'll have a fancy terminal inside of coder-server.
74+
75+
<b>Install font for Oh My Zsh theme</b><br />
76+
Download the font, install it and set it in code-server. You can follow the Visual Studio Code guide provided in the same link as the font.<br />
77+
https://github.com/romkatv/powerlevel10k#manual-font-installation
78+
79+
<b>Open .zshrc and change theme to</b><br />
80+
`ZSH_THEME="powerlevel10k/powerlevel10k"`<br />
81+
You can also use any other theme if you prefer something else.
82+
83+
Installing font for Oh My Zsh theme
84+
https://github.com/romkatv/powerlevel10k#manual-font-installation
85+
86+
## Post-installation
87+
You can now install Docker and any other extensions you might want.
88+
89+
### Example of finished set-up
90+
<p>
91+
<img width="600" src="https://i.imgur.com/fLjvVRn.png">
92+
</p>
93+
94+
# 🐛 Known issues
95+
- None so far 👀
96+

_base/compose/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
COMPOSE_PROJECT_NAME=base
2+
3+
# Data directory
4+
DATA_DIR=../data

_base/compose/docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.8'
2+
3+
services:
4+
5+
traefik:
6+
image: traefik:2.8
7+
env_file:
8+
- .env
9+
networks:
10+
- global
11+
restart: always
12+
ports:
13+
- "80:80"
14+
- "443:443"
15+
volumes:
16+
- /var/run/docker.sock:/var/run/docker.sock
17+
- ${DATA_DIR}/traefik/traefik.toml:/etc/traefik/traefik.toml
18+
- ${DATA_DIR}/traefik/acme.json:/acme.json
19+
- ${DATA_DIR}/traefik/.htpasswd:/.htpasswd
20+
labels:
21+
- "traefik.http.middlewares.basic-auth.basicauth.usersfile=/.htpasswd"
22+
23+
networks:
24+
global:
25+
external: true

_base/data/traefik/.htpasswd

Whitespace-only changes.

_base/data/traefik/acme.json

Whitespace-only changes.

_base/data/traefik/traefik.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[global]
2+
checkNewVersion = false
3+
sendAnonymousUsage = false
4+
5+
[entryPoints]
6+
[entryPoints.web]
7+
address = ":80"
8+
9+
[entryPoints.websecure]
10+
address = ":443"
11+
12+
[providers.docker]
13+
14+
[certificatesResolvers.letsencrypt.acme]
15+
email = "admin@example.com"
16+
storage = "acme.json"
17+
[certificatesResolvers.letsencrypt.acme.httpChallenge]
18+
entryPoint = "web"

code-server/compose/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
COMPOSE_PROJECT_NAME=code_server
2+
3+
DATA_DIR=../data
4+
DOMAIN=
5+
PASSWORD=
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '3'
2+
services:
3+
4+
vscode:
5+
image: vscodesrv
6+
user: "1000:113" # Your user ID : Docker group ID
7+
networks:
8+
- global
9+
- local
10+
environment:
11+
- PASSWORD=${PASSWORD}
12+
- DOCKER_USER=${USER}
13+
volumes:
14+
- /var/run/docker.sock:/var/run/docker.sock
15+
- ${DATA_DIR}/code-server:/home/coder
16+
labels:
17+
- "traefik.enable=true"
18+
# HTTP
19+
- "traefik.http.routers.code_server.entrypoints=web"
20+
- "traefik.http.routers.code_server.rule=Host(`${DOMAIN}`)"
21+
- "traefik.http.routers.code_server.middlewares=code_server_https"
22+
- "traefik.http.middlewares.code_server_https.redirectscheme.scheme=https"
23+
# HTTPS
24+
- "traefik.http.routers.code_server-https.entrypoints=websecure"
25+
- "traefik.http.routers.code_server-https.rule=Host(`${DOMAIN}`)"
26+
- "traefik.http.routers.code_server-https.tls=true"
27+
- "traefik.http.routers.code_server-https.tls.certresolver=letsencrypt"
28+
- "traefik.http.services.code_server-https.loadbalancer.server.port=8080"
29+
# Basic auth
30+
- "traefik.http.routers.code_server-auth.rule=Host(`${DOMAIN}`)"
31+
- "traefik.http.routers.code_server-auth.middlewares=basic-auth"
32+
- "traefik.http.routers.code_server-auth.tls=true"
33+
34+
networks:
35+
local:
36+
external: false
37+
global:
38+
external: true

code-server/data/code-server/.data

Whitespace-only changes.

0 commit comments

Comments
 (0)