Skip to content

Commit 5c44a0a

Browse files
committed
initial commit
0 parents  commit 5c44a0a

File tree

7 files changed

+215
-0
lines changed

7 files changed

+215
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
buildAndRelease:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
# needed for creating a release
14+
contents: write
15+
# needed for pushing docker image
16+
attestations: write
17+
id-token: write
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up jq
25+
run: |
26+
sudo apt-get update && sudo apt-get install jq -y
27+
28+
- name: Set up Name and Version
29+
id: releases
30+
run: |
31+
NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}
32+
THIS_REPO=https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest
33+
TARGET_REPO=https://api.github.com/repos/coder/code-server/releases/latest
34+
CURRENT_VERSION=$(curl -s $THIS_REPO | jq -r '.tag_name // empty')
35+
TARGET_VERSION=$(curl -s $TARGET_REPO | jq -r '.tag_name // empty')
36+
RELEASE_URL=$(curl -s $TARGET_REPO | jq -r '.html_url')
37+
echo "VERSION=${TARGET_VERSION}" >> $GITHUB_ENV
38+
echo "NAME=${NAME}" >> $GITHUB_ENV
39+
echo "url=${RELEASE_URL}" >> $GITHUB_OUTPUT
40+
echo "current=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
41+
echo "target=${TARGET_VERSION}" >> $GITHUB_OUTPUT
42+
echo Using NAME=$NAME, TARGET_VERSION=$TARGET_VERSION, CURRENT_VERSION=$CURRENT_VERSION, RELEASE_URL=$RELEASE_URL
43+
44+
- name: Set up Docker
45+
uses: docker/setup-buildx-action@v2
46+
47+
- name: Build Docker image
48+
env:
49+
VERSION: ${{ steps.releases.outputs.target }}
50+
run: |
51+
docker build --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` -t ghcr.io/${{ github.repository_owner }}/$NAME:$VERSION .
52+
docker tag ghcr.io/${{ github.repository_owner }}/$NAME:$VERSION ghcr.io/${{ github.repository_owner }}/$NAME:latest
53+
54+
- name: Create GitHub Release
55+
uses: softprops/action-gh-release@v2
56+
if: steps.releases.outputs.current != steps.releases.outputs.target
57+
env:
58+
VERSION: ${{ steps.releases.outputs.target }}
59+
with:
60+
name: Update to ${{ steps.releases.outputs.target }}
61+
tag_name: ${{ steps.releases.outputs.target }}
62+
body: See release notes [here](${{ steps.releases.outputs.url }})
63+
64+
- name: Log in to GitHub Container Registry
65+
uses: docker/login-action@v3
66+
if: steps.releases.outputs.current != steps.releases.outputs.target
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Push Docker image
73+
if: steps.releases.outputs.current != steps.releases.outputs.target
74+
env:
75+
VERSION: ${{ steps.releases.outputs.target }}
76+
run: |
77+
docker push ghcr.io/${{ github.repository_owner }}/$NAME:$VERSION
78+
docker push ghcr.io/${{ github.repository_owner }}/$NAME:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.sh

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM fedora:latest
2+
3+
ARG VERSION
4+
5+
COPY run.sh /app/code-server/run.sh
6+
7+
RUN \
8+
echo "**** install runtime dependencies ****" && \
9+
dnf update -y && \
10+
dnf install -y curl nano wget net-tools openssl git nodejs golang python3 && \
11+
echo "**** install code-server ****" && \
12+
CODE_RELEASE=$(echo $VERSION | sed 's|^v||') && \
13+
mkdir -p /app/code-server && \
14+
mkdir -p /workspace && \
15+
curl -o \
16+
/tmp/code-server.tar.gz -L \
17+
"https://github.com/coder/code-server/releases/download/v${CODE_RELEASE}/code-server-${CODE_RELEASE}-linux-amd64.tar.gz" && \
18+
tar xf /tmp/code-server.tar.gz -C \
19+
/app/code-server --strip-components=1 && \
20+
chmod +x /app/code-server/bin/code-server /app/code-server/run.sh && \
21+
echo "**** clean up ****" && \
22+
dnf clean all && \
23+
rm -rf \
24+
/tmp/* \
25+
/var/tmp/*
26+
27+
COPY bashrc /workspace/.bashrc
28+
29+
EXPOSE 8080
30+
31+
ENTRYPOINT [ "/app/code-server/run.sh" ]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Jan Weidenhaupt
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# code-server docker
2+
3+
[![Build and Release](https://github.com/jamowei/code-server/actions/workflows/buildAndRelease.yaml/badge.svg)](https://github.com/jamowei/code-server/actions/workflows/buildAndRelease.yaml)
4+
5+
Run [VS Code](https://github.com/Microsoft/vscode) on
6+
any [Docker](https://www.docker.com/) host and use it in the browser.
7+
8+
The Docker image is based on latest [Fedora Linux](https://hub.docker.com/_/fedora) image
9+
and starts the great [code-server](https://github.com/coder/code-server) inside.
10+
11+
## Run it
12+
13+
```
14+
docker run --rm --name code-server \
15+
-p 8080:8080 \
16+
-e PASSWORD=mypassword \
17+
-v /my/workspace:/workspace \
18+
ghcr.io/jamowei/code-server:latest
19+
```
20+
21+
Then open http://localhost:8080/
22+
23+
## Environment Variables
24+
25+
| Name | Default Value | Description |
26+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
27+
| LOCALE | `en` | Set the locale of vs-code. See available [here](https://code.visualstudio.com/docs/getstarted/locales#_available-locales) |
28+
| PASSWORD | `changeit` | Password for using code-server |
29+
| EXTENSIONS | `golang.go\|ms-python.python\|ms-python.debugpy\|eamodio.gitlens\|humao.rest-client\|esbenp.prettier-vscode\|dbaeumer.vscode-eslint\|ecmel.vscode-html-css\|pkief.material-icon-theme\|k--kato.intellij-idea-keybindings` | List of vs-code extensions-ids, separated by `\|` |
30+
31+
## Build it
32+
33+
Get the latest released `VERSION` of [code-server](https://github.com/coder/code-server)
34+
from [here](https://github.com/coder/code-server/releases).
35+
```
36+
docker build --build-arg VERSION=v4.96.4 -t myrepo/code-server:v1.0 .
37+
```

bashrc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# .bashrc
2+
3+
# Source global definitions
4+
if [ -f /etc/bashrc ]; then
5+
. /etc/bashrc
6+
fi
7+
8+
# User specific environment
9+
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
10+
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
11+
fi
12+
export PATH
13+
14+
# Uncomment the following line if you don't like systemctl's auto-paging feature:
15+
# export SYSTEMD_PAGER=
16+
17+
# User specific aliases and functions
18+
if [ -d ~/.bashrc.d ]; then
19+
for rc in ~/.bashrc.d/*; do
20+
if [ -f "$rc" ]; then
21+
. "$rc"
22+
fi
23+
done
24+
fi
25+
unset rc
26+
27+
alias cd..='cd ..'
28+
29+
function parse_git_dirty {
30+
[[ $(git status --porcelain 2> /dev/null) ]] && echo "*"
31+
}
32+
function parse_git_branch {
33+
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
34+
}
35+
36+
export PS1="\t \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

run.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
export HOME="/workspace"
4+
LOCALE="${LOCALE:-en}"
5+
PASSWORD="${PASSWORD:-changeit}"
6+
EXTENSIONS="${EXTENSIONS:-golang.go|ms-python.python|ms-python.debugpy|eamodio.gitlens|humao.rest-client|esbenp.prettier-vscode|dbaeumer.vscode-eslint|ecmel.vscode-html-css|pkief.material-icon-theme|k--kato.intellij-idea-keybindings}"
7+
8+
dnf update -y
9+
10+
/app/code-server/bin/code-server --install-extension ${EXTENSIONS//|/ --install-extension }
11+
/app/code-server/bin/code-server --disable-telemetry --disable-workspace-trust --locale ${LOCALE} --bind-addr 0.0.0.0:8080

0 commit comments

Comments
 (0)