Skip to content

Commit bb17fe6

Browse files
committed
Add workspace
1 parent 764d5bb commit bb17fe6

2 files changed

Lines changed: 149 additions & 0 deletions

File tree

‎.github/workflows/workspace.yaml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: workspace
2+
3+
on:
4+
schedule:
5+
- cron: "0 10 * * *"
6+
push:
7+
branches:
8+
- "**"
9+
tags:
10+
- "v*.*.*"
11+
pull_request:
12+
branches:
13+
- "main"
14+
15+
jobs:
16+
workspace:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Set variables useful for later
20+
id: useful_vars
21+
run: |-
22+
echo "::set-output name=timestamp::$(date +%s)"
23+
echo "::set-output name=short_sha::${GITHUB_SHA::8}"
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Docker meta
27+
id: docker_meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
images: ghcr.io/${{ github.repository }}/workspace
31+
tags: |
32+
type=schedule
33+
type=ref,event=branch
34+
type=ref,event=pr
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
type=semver,pattern={{major}}
38+
type=sha,prefix=,format=long,event=tag
39+
type=sha
40+
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
41+
type=raw,value=${{ github.ref_name }}-${{ steps.useful_vars.outputs.short_sha }}-${{ steps.useful_vars.outputs.timestamp }},enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v2
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v2
46+
- name: Login to GHCR
47+
if: github.event_name != 'pull_request'
48+
uses: docker/login-action@v2
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
- name: Cache Docker layers
54+
uses: actions/cache@v3
55+
with:
56+
path: /tmp/.buildx-cache
57+
key: ${{ runner.os }}-workspace-buildx-${{ github.sha }}
58+
restore-keys: |
59+
${{ runner.os }}-workspace-buildx-
60+
- name: Build and push
61+
uses: docker/build-push-action@v4
62+
with:
63+
context: workspace
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.docker_meta.outputs.tags }}
66+
labels: ${{ steps.docker_meta.outputs.labels }}
67+
platforms: linux/amd64,linux/arm64
68+
cache-from: type=local,src=/tmp/.buildx-cache
69+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

‎workspace/Dockerfile‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
FROM alpine:edge
2+
3+
RUN apk add --no-cache \
4+
build-base cmake ninja pkgconf automake autoconf libtool \
5+
rust cargo go \
6+
python3 py3-pip python3-dev py3-virtualenv \
7+
bash zsh fish tmux screen \
8+
vim neovim nano less \
9+
curl wget ca-certificates openssh sshpass rsync socat nmap \
10+
ripgrep fd fzf tree eza bat unzip zip tar gzip bzip2 xz zstd \
11+
htop btop iotop iftop nvtop \
12+
git git-lfs lazygit \
13+
docker-cli docker-cli-compose \
14+
podman podman-docker fuse-overlayfs slirp4netns shadow \
15+
jq yq httpie shellcheck shfmt make direnv starship \
16+
tzdata \
17+
nix \
18+
ruby ruby-dev openjdk17 \
19+
tidyhtml libxml2-utils \
20+
&& cp /usr/share/zoneinfo/UTC /etc/localtime \
21+
&& echo "UTC" > /etc/timezone
22+
23+
RUN addgroup -g 1000 -S user \
24+
&& adduser -u 1000 -S -G user -s /bin/bash -h /home/user user \
25+
&& mkdir -p /home/user/.local/bin /home/user/.cache \
26+
&& chown -R user:user /home/user
27+
28+
# Rootless podman requires subuid/subgid mapping
29+
RUN echo "user:100000:65536" >> /etc/subuid \
30+
&& echo "user:100000:65536" >> /etc/subgid
31+
32+
RUN addgroup nixbld \
33+
&& for i in $(seq 1 4); do adduser -S -D -H -G nixbld nixbld$i; done \
34+
&& mkdir -p /etc/nix \
35+
&& printf "allowed-users = @nix\nbuild-users-group = nixbld\nmax-jobs = 4\nextra-experimental-features = nix-command flakes\n" > /etc/nix/nix.conf \
36+
&& printf '#!/sbin/openrc-run\ndescription="Nix daemon"\ncommand="/usr/sbin/nix-daemon"\ncommand_background="yes"\npidfile="/run/nix-daemon.pid"\n' > /etc/init.d/nix-daemon \
37+
&& chmod +x /etc/init.d/nix-daemon \
38+
&& rc-update add nix-daemon default
39+
40+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
41+
&& mv /root/.local/bin/uv /usr/local/bin/uv \
42+
&& mv /root/.local/bin/uvx /usr/local/bin/uvx
43+
44+
USER user
45+
RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
46+
&& . "$HOME/.nvm/nvm.sh" \
47+
&& nvm install --lts \
48+
&& nvm alias default lts/* \
49+
&& nvm use default \
50+
&& npm install -g npm@latest yarn pnpm typescript ts-node prettier eslint \
51+
&& curl -fsSL https://bun.sh/install | bash
52+
53+
USER root
54+
RUN pip install --no-cache-dir --break-system-packages black yapf isort flake8 mypy \
55+
&& gem install rubocop
56+
57+
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> /home/user/.bashrc \
58+
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' >> /home/user/.bashrc \
59+
&& echo 'export BUN_INSTALL="$HOME/.bun"' >> /home/user/.bashrc \
60+
&& echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> /home/user/.bashrc \
61+
&& echo 'export GOPATH="$HOME/go"' >> /home/user/.bashrc \
62+
&& echo 'export PATH="$GOPATH/bin:$PATH"' >> /home/user/.bashrc \
63+
&& echo 'eval "$(starship init bash)"' >> /home/user/.bashrc \
64+
&& echo 'eval "$(direnv hook bash)"' >> /home/user/.bashrc \
65+
&& cp /home/user/.bashrc /home/user/.zshrc \
66+
&& sed -i 's/bash/zsh/g' /home/user/.zshrc \
67+
&& echo 'eval "$(starship init zsh)"' >> /home/user/.zshrc \
68+
&& echo 'eval "$(direnv hook zsh)"' >> /home/user/.zshrc \
69+
&& chown -R user:user /home/user
70+
71+
USER user
72+
WORKDIR /home/user
73+
ENV HOME=/home/user \
74+
SHELL=/bin/bash \
75+
LANG=C.UTF-8 \
76+
LC_ALL=C.UTF-8 \
77+
TERM=xterm-256color \
78+
PATH=/home/user/.local/bin:/home/user/.bun/bin:/home/user/go/bin:$PATH
79+
80+
CMD ["sleep", "infinity"]

0 commit comments

Comments
 (0)