Workflow: Add docker image generation
This commit is contained in:
parent
0c50e2a651
commit
c54f961873
84
.github/workflows/Dockerfile
vendored
Normal file
84
.github/workflows/Dockerfile
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
FROM ubuntu:20.04
|
||||
MAINTAINER TEC <tec@tecosaur.com>
|
||||
|
||||
ENV LANG=C.UTF-8
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN echo "\033[1;34mAdd Emacs PPA.\033[0m" &&\
|
||||
apt-get update &&\
|
||||
apt-get install -y apt-utils software-properties-common sudo &&\
|
||||
add-apt-repository -y ppa:kelleyk/emacs
|
||||
|
||||
RUN echo "\033[1;34mUpdate.\033[0m" &&\
|
||||
apt-get update &&\
|
||||
## Modified version of https://github.com/thomasWeise/docker-texlive-full
|
||||
# prevent doc and man pages from being installed
|
||||
# the idea is based on https://askubuntu.com/questions/129566
|
||||
echo "\033[1;34mPreventing doc and man pages from being installed.\033[0m" &&\
|
||||
printf 'path-exclude /usr/share/doc/*\npath-include /usr/share/doc/*/copyright\npath-exclude /usr/share/man/*\npath-exclude /usr/share/groff/*\npath-exclude /usr/share/info/*\npath-exclude /usr/share/lintian/*\npath-exclude /usr/share/linda/*\npath-exclude=/usr/share/locale/*' > /etc/dpkg/dpkg.cfg.d/01_nodoc &&\
|
||||
# remove doc files and man pages already installed
|
||||
rm -rf /usr/share/groff/* /usr/share/info/* &&\
|
||||
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/man/* &&\
|
||||
rm -rf /usr/share/man &&\
|
||||
mkdir -p /usr/share/man &&\
|
||||
find /usr/share/doc -depth -type f ! -name copyright -delete &&\
|
||||
find /usr/share/doc -type f -name "*.pdf" -delete &&\
|
||||
find /usr/share/doc -type f -name "*.gz" -delete &&\
|
||||
find /usr/share/doc -type f -name "*.tex" -delete &&\
|
||||
(find /usr/share/doc -type d -empty -delete || true) &&\
|
||||
mkdir -p /usr/share/doc &&\
|
||||
mkdir -p /usr/share/info &&\
|
||||
echo "\033[1;34mInstalling utilities.\033[0m" &&\
|
||||
apt-get install -y git gcc sqlite sqlite3 wget ncurses-term ripgrep xclip &&\
|
||||
echo "\033[1;34mInstalling Emacs\033[0m" &&\
|
||||
# Emacs 27.1 (nox)
|
||||
apt-get install -y emacs27-nox &&\
|
||||
echo "\033[1;34mInstalling TeX Live packages.\033[0m" &&\
|
||||
# install TeX Live and ghostscript as well as other tools
|
||||
git clone https://github.com/tecosaur/BMC.git /usr/share/texmf/tex/latex/bmc &&\
|
||||
apt-get install -y texlive-base texlive-latex-recommended texlive-fonts-extra latexmk &&\
|
||||
# delete Tex Live sources and other potentially useless stuff
|
||||
echo "\033[1;34mDelete TeX Live sources and other useless stuff.\033[0m" &&\
|
||||
(rm -rf /usr/share/texmf/source || true) &&\
|
||||
(rm -rf /usr/share/texlive/texmf-dist/source || true) &&\
|
||||
find /usr/share/texlive -type f -name "readme*.*" -delete &&\
|
||||
find /usr/share/texlive -type f -name "README*.*" -delete &&\
|
||||
(rm -rf /usr/share/texlive/release-texlive.txt || true) &&\
|
||||
(rm -rf /usr/share/texlive/doc.html || true) &&\
|
||||
(rm -rf /usr/share/texlive/index.html || true) &&\
|
||||
# clean up all temporary files
|
||||
echo "\033[1;34mClean up all temporary files.\033[0m" &&\
|
||||
apt-get clean -y &&\
|
||||
rm -rf /var/lib/apt/lists/* &&\
|
||||
rm -f /etc/ssh/ssh_host_* &&\
|
||||
# delete man pages and documentation
|
||||
echo "\033[1;34mDelete man pages and documentation.\033[0m" &&\
|
||||
rm -rf /usr/share/man &&\
|
||||
mkdir -p /usr/share/man &&\
|
||||
find /usr/share/doc -depth -type f ! -name copyright -delete &&\
|
||||
find /usr/share/doc -type f -name "*.pdf" -delete &&\
|
||||
find /usr/share/doc -type f -name "*.gz" -delete &&\
|
||||
find /usr/share/doc -type f -name "*.tex" -delete &&\
|
||||
(find /usr/share/doc -type d -empty -delete || true) &&\
|
||||
mkdir -p /usr/share/doc &&\
|
||||
rm -rf /var/cache/apt/archives &&\
|
||||
mkdir -p /var/cache/apt/archives &&\
|
||||
rm -rf /tmp/* /var/tmp/* &&\
|
||||
(find /usr/share/ -type f -empty -delete || true) &&\
|
||||
(find /usr/share/ -type d -empty -delete || true) &&\
|
||||
mkdir -p /usr/share/texmf/source &&\
|
||||
mkdir -p /usr/share/texlive/texmf-dist/source &&\
|
||||
echo "\033[1;32mAll done.\033[0m"
|
||||
|
||||
RUN echo "\033[1;36mDon't check github's SSH key\033[0m" &&\
|
||||
printf "Host github.com\n StrictHostKeyChecking no\n" >> /etc/ssh/ssh_config
|
||||
|
||||
RUN echo "\033[1;36mAdd non-root user.\033[0m" &&\
|
||||
groupadd runner &&\
|
||||
useradd -m -g runner -G sudo -u 1000 -c "Docker image runner" runner &&\
|
||||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers &&\
|
||||
echo "Add command to run command with user 'runner'" &&\
|
||||
printf '#!/usr/bin/env sh\nsudo -i -u runner bash <<EOF\n$@\nEOF\n' > /bin/runner &&\
|
||||
chmod +x /bin/runner
|
||||
|
||||
USER runner
|
33
.github/workflows/buildimage.yml
vendored
Normal file
33
.github/workflows/buildimage.yml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
name: "Build Image"
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
paths:
|
||||
- ".github/workflows/Dockerfile"
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-20.04 # change to -latest when possible
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to the GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Push to Docker Hub
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .github/workflows
|
||||
tags: ghcr.io/tecosaur/emacs-config:latest
|
||||
push: true
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
58
.github/workflows/publish.yml
vendored
58
.github/workflows/publish.yml
vendored
|
@ -9,69 +9,47 @@ on:
|
|||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-20.04 # change to -latest when possible
|
||||
container:
|
||||
image: ghcr.io/tecosaur/emacs-config:latest
|
||||
options: --user 0 # root
|
||||
credentials:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: purcell/setup-emacs@master
|
||||
with:
|
||||
version: 27.1
|
||||
|
||||
- name: Checkout config
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Symlink config to expected location
|
||||
# I could just set DOOMDIR ... but this is also easy
|
||||
run: |
|
||||
mkdir -p ~/.config
|
||||
ln -s $GITHUB_WORKSPACE ~/.config/doom
|
||||
mkdir -p ~/.org/roam
|
||||
run: runner 'git clone --depth 1 --recurse-submodules https://github.com/tecosaur/emacs-config.git ~/.config/doom'
|
||||
|
||||
- name: Generate init.el et. al from config.org
|
||||
run: |
|
||||
cd ~/.config/doom
|
||||
emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "config.org")'
|
||||
run: runner "cd ~/.config/doom && emacs --batch --eval \"(require 'org)\" --eval '(org-babel-tangle-file \"config.org\")'"
|
||||
|
||||
- name: Clone Doom to ~/.emacs.d
|
||||
run: git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
|
||||
run: runner 'git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d'
|
||||
|
||||
- name: Get Doom's version
|
||||
id: doom-version
|
||||
run: |
|
||||
cd ~/.emacs.d
|
||||
echo ::set-output name=hash::$(git log -1 | head -1 | awk '{print substr($2,1,7)}')
|
||||
shell: bash
|
||||
run: runner 'cd ~/.emacs.d && echo "::set-output name=hash::$(git log -1 | head -1 | awk '"'"'{print substr($2,1,7)}'"'"')"'
|
||||
|
||||
- name: Cache Doom's install
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.emacs.d
|
||||
path: /home/runner/.emacs.d
|
||||
key: ${{ runner.os }}-doom@${{ steps.doom-version.outputs.hash }}
|
||||
|
||||
- name: Doom dependencies
|
||||
run: sudo apt-get install git ripgrep xclip
|
||||
|
||||
- name: Install Doom
|
||||
run: ~/.emacs.d/bin/doom install --no-env --no-fonts
|
||||
|
||||
- name: Install LaTeX compiler chain
|
||||
run: |
|
||||
git clone https://github.com/tecosaur/BMC.git ~/texmf/tex/latex/bmc
|
||||
sudo apt install texlive-base texlive-latex-recommended texlive-fonts-extra latexmk
|
||||
run: runner '~/.emacs.d/bin/doom install --no-env --no-fonts'
|
||||
|
||||
- name: Export config
|
||||
run: |
|
||||
cd ~/.config/doom/misc/config-publishing
|
||||
./publish.sh
|
||||
|
||||
# - name: Debug over SSH (tmate)
|
||||
# if: ${{ failure() }}
|
||||
# uses: mxschmitt/action-tmate@v3.1
|
||||
run: runner 'cd ~/.config/doom/misc/config-publishing && ./publish.sh'
|
||||
|
||||
- name: Deploy
|
||||
if: ${{ github.event_name != 'pull_request'}}
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||
publish_dir: ./publish
|
||||
publish_dir: /home/runner/.config/doom/publish
|
||||
force_orphan: true
|
||||
|
||||
- name: Debug over SSH (tmate)
|
||||
if: ${{ failure() }}
|
||||
uses: mxschmitt/action-tmate@v3.1
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,3 +10,5 @@ setup.sh
|
|||
|
||||
!publish
|
||||
!publish/config.html
|
||||
|
||||
!.github
|
||||
|
|
Loading…
Reference in a new issue