Skip to content

Instantly share code, notes, and snippets.

@jscheid
Last active July 9, 2021 11:10
Show Gist options
  • Save jscheid/84af350a6115067c92c0181cbb94810b to your computer and use it in GitHub Desktop.
Save jscheid/84af350a6115067c92c0181cbb94810b to your computer and use it in GitHub Desktop.
Running makem in Docker
Dockerfile
/.sandbox/
/.git/
/.sandbox/
*.elc
#!/bin/sh
# * License:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -eou pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
mkdir -p "$DIR/.sandbox"
exec docker run \
--mount type=bind,source="$DIR",target=/src \
--mount type=bind,source="$DIR/.sandbox",target=/sandbox \
--entrypoint=/usr/bin/emacs \
--interactive \
--tty \
$(docker build . --quiet) \
--eval "(setq user-emacs-directory (file-truename (concat \"/sandbox/\" emacs-version \"/\")))" \
--eval "(setq user-init-file (file-truename (concat \"/sandbox/\" emacs-version \"/init.el\")))" \
--eval "(progn (require 'package) (package-initialize))" \
"$@"
#!/bin/bash
# * License:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -eou pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
mkdir -p "$DIR/.sandbox"
exec docker run \
--mount type=bind,source="$DIR",target=/src \
--mount type=bind,source="$DIR/.sandbox",target=/sandbox \
$(docker build . --quiet) \
"$@"
# * License:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM alpine:3.13
RUN apk update && apk add --no-cache \
aspell \
aspell-en \
bash \
ca-certificates \
coreutils \
emacs \
git \
make
RUN adduser -D emacs
USER emacs
WORKDIR /src
ENTRYPOINT ["make", "sandbox=/sandbox"]
@jscheid
Copy link
Author

jscheid commented Feb 19, 2021

To use this, add these files alongside makem.sh and Makefile. Then, cd to the directory and use e.g. ./dmake lint to run a makem command, or ./demacs to run Emacs inside Docker.

@alphapapa
Copy link

Thanks, that's very cool. I made an issue for this: alphapapa/makem.sh#33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment