Skip to content

Commit fecbc2b

Browse files
committed
Add docker image.
1 parent 4d9a0d4 commit fecbc2b

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

.github/workflows/docker.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: Image
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- Dockerfile
9+
workflow_dispatch:
10+
inputs:
11+
ref:
12+
description: "Git ref to build the image from"
13+
required: false
14+
default: "main"
15+
16+
concurrency:
17+
group: image-workflow
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.inputs.ref }}
27+
28+
- run: >
29+
echo "IMAGE_TAG=${{ (inputs.ref || github.ref_name) == 'main' &&
30+
'latest' || (inputs.ref || github.ref_name) }}" >> $GITHUB_ENV
31+
32+
- name: Build Docker Image
33+
run: |
34+
docker build -t fnando/screenkit:${{ env.IMAGE_TAG }} .
35+
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
40+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
41+
42+
- name: Push Docker Image
43+
run: |
44+
docker push fnando/screenkit:${{ env.IMAGE_TAG }}

Dockerfile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Stage 1: Download and extract fonts
2+
FROM --platform=linux/amd64 alpine:latest AS fonts
3+
RUN apk add --no-cache curl unzip
4+
RUN mkdir /fonts && \
5+
curl -sSL -o JetBrainsMono.zip https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/JetBrainsMono.zip && \
6+
unzip -j JetBrainsMono.zip 'JetBrainsMonoNerdFontPropo-*.ttf' -d /fonts
7+
8+
# Stage 2: Download binaries
9+
FROM --platform=linux/amd64 alpine:latest AS binaries
10+
ARG SLIDES_VERSION=0.9.0
11+
ARG TTYD_VERSION=1.7.7
12+
ARG LL_VERSION=0.0.11
13+
ARG BAT_VERSION=0.26.0
14+
RUN apk add --no-cache curl
15+
RUN mkdir /bin-download && cd /bin-download && \
16+
curl -sSL https://github.com/maaslalani/slides/releases/download/v${SLIDES_VERSION}/slides_${SLIDES_VERSION}_linux_amd64.tar.gz | tar xz && \
17+
curl -sSL https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.x86_64 > ttyd && \
18+
curl -sSL https://github.com/fnando/ll/releases/download/v${LL_VERSION}/ll-x86_64-unknown-linux-gnu.tar.gz | tar xz && \
19+
curl -sSL https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-v${BAT_VERSION}-x86_64-unknown-linux-musl.tar.gz | tar xz && \
20+
mv bat-v${BAT_VERSION}-x86_64-unknown-linux-musl/bat . && \
21+
chmod +x slides ttyd ll bat
22+
23+
# Stage 3: Final image
24+
FROM --platform=linux/amd64 ruby:3.4-alpine
25+
26+
# Install runtime dependencies and build tools
27+
RUN apk add --no-cache \
28+
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \
29+
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
30+
bash \
31+
bash-completion \
32+
build-base \
33+
ca-certificates \
34+
chromium \
35+
chromium-chromedriver \
36+
curl \
37+
fish \
38+
ffmpeg \
39+
font-liberation \
40+
font-noto \
41+
font-noto-emoji \
42+
freetype \
43+
git \
44+
gtk+3.0 \
45+
harfbuzz \
46+
imagemagick \
47+
jq \
48+
less \
49+
mesa-gl \
50+
nss \
51+
python3 \
52+
py3-pip \
53+
py3-virtualenv \
54+
sudo \
55+
ttf-dejavu \
56+
ttf-freefont \
57+
udev \
58+
zsh \
59+
&& fc-cache -f
60+
61+
ARG USER=screenkit
62+
ENV TERM=xterm-256color
63+
ENV PATH="/venv/bin:/source/bin:/${USER}/bin:$PATH"
64+
ENV CHROME_BIN=/usr/bin/chromium-browser
65+
ENV CHROME_PATH=/usr/lib/chromium/
66+
67+
# Copy binaries and fonts from builder stages
68+
COPY --from=binaries /bin-download/slides /usr/local/bin/slides
69+
COPY --from=binaries /bin-download/ttyd /usr/local/bin/ttyd
70+
COPY --from=binaries /bin-download/ll /usr/local/bin/ll
71+
COPY --from=binaries /bin-download/bat /usr/local/bin/bat
72+
COPY --from=fonts /fonts /usr/local/share/fonts
73+
74+
# Update font cache
75+
RUN fc-cache -f
76+
77+
# Create user
78+
RUN adduser -D -h /${USER} -s /bin/zsh -u 1001 ${USER} \
79+
&& chown -R ${USER}:${USER} /${USER} \
80+
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER} \
81+
&& chmod 0440 /etc/sudoers.d/${USER}
82+
83+
RUN mkdir -p /venv && chown -R ${USER}:${USER} /venv
84+
RUN mkdir -p /${USER}-local && chown -R ${USER}:${USER} /${USER}-local
85+
86+
# Install screenkit gem
87+
RUN gem install screenkit && \
88+
mkdir -p /usr/share/bash-completion/completions && \
89+
mkdir -p /usr/share/zsh/site-functions && \
90+
mkdir -p /usr/share/fish/vendor_completions.d && \
91+
screenkit completion --shell bash > /usr/share/bash-completion/completions/screenkit && \
92+
screenkit completion --shell zsh > /usr/share/zsh/site-functions/_screenkit && \
93+
screenkit completion --shell fish > /usr/share/fish/vendor_completions.d/screenkit.fish && \
94+
echo 'autoload -Uz compinit && compinit' >> /etc/zsh/zshrc && \
95+
echo 'source /usr/share/bash-completion/bash_completion' >> /etc/bash/bashrc && \
96+
apk del build-base
97+
98+
USER ${USER}
99+
WORKDIR /${USER}
100+
101+
# Create Python virtual environment
102+
RUN python3 -m venv /venv
103+
RUN /venv/bin/pip install ffmpeg-normalize
104+
105+
WORKDIR /source
106+
107+
ENTRYPOINT [ "screenkit" ]

0 commit comments

Comments
 (0)