From 68dd741c36442c7ca8645f130746e4f11c6183a2 Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Sat, 6 May 2023 15:17:58 +0200 Subject: [PATCH] Update emacs ido config + make finding docker executable on host more robust --- Dockerfile | 25 +++++--- Dockerfile.aarch64 | 149 +++++++++++++++++++++++++++++++++++++++++++++ emacs/init.el | 25 ++++++-- main.go | 6 +- 4 files changed, 190 insertions(+), 15 deletions(-) create mode 100644 Dockerfile.aarch64 diff --git a/Dockerfile b/Dockerfile index 5cdb788..e38b154 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ libmagickwand-dev imagemagick libacl1-dev libxml2-dev -RUN wget https://ftp.gnu.org/gnu/emacs/emacs-28.1.tar.gz \ +RUN wget https://ftp.gnu.org/gnu/emacs/emacs-28.2.tar.gz \ -O /tmp/emacs.tar.gz WORKDIR /tmp/emacs @@ -47,7 +47,7 @@ RUN sed -i 's!static unsigned char sigsegv_stack\[SIGSTKSZ\]!static max_align_t RUN make install RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ - libreadline8 bash-completion sudo tzdata + libreadline8 bash-completion sudo tzdata libtool-bin RUN apt-get update && apt-get -y install \ php8.1-memcached \ @@ -75,12 +75,20 @@ RUN apt-get update && apt-get -y install \ php-apcu \ php-cli \ php-imagick \ - composer \ + php-intl \ php-xdebug +WORKDIR /tmp -run mkdir -p /opt/nodejs -RUN curl --location "https://nodejs.org/dist/v17.8.0/node-v17.8.0-linux-x64.tar.xz" | tar -Jxf - --strip-components=1 -C /opt/nodejs/ +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ + && php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ + && php composer-setup.php \ + && php -r "unlink('composer-setup.php');" +RUN mv composer.phar /usr/bin/composer + + +RUN mkdir -p /opt/nodejs +RUN curl --location "https://nodejs.org/dist/v19.8.1/node-v19.8.1-linux-x64.tar.xz" | tar -Jxf - --strip-components=1 -C /opt/nodejs/ # Make nodejs dir world-writable. This shouldn't be a problem as the container # will, naturally only have a single user that has acces to the volume. RUN chmod -R 777 /opt/nodejs @@ -96,11 +104,11 @@ RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o / RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install docker-ce-cli apt-file RUN apt-file update -RUN curl -fsSL https://github.com/drone/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz \ +RUN curl -fsSL https://github.com/woodpecker-ci/woodpecker/releases/download/v0.15.7/woodpecker-cli_linux_amd64.tar.gz \ | tar -xzf - -C /usr/bin/ -RUN curl --location "https://golang.org/dl/go1.18.linux-amd64.tar.gz" | tar -xzf - -C /usr/local/ +RUN curl --location "https://golang.org/dl/go1.20.linux-amd64.tar.gz" | tar -xzf - -C /usr/local/ #RUN ln -s /usr/local/go/bin/* /usr/local/bin/ RUN GOPATH=/usr/local/gopkg /bin/bash -c 'for package in \ @@ -132,12 +140,13 @@ RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install proto RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install html2text wkhtmltopdf pandoc ispell idutch irussian ienglish-common offlineimap3 maildir-utils -RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-client +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-client iputils-ping unzip RUN curl -L https://github.com/storj/storj/releases/latest/download/uplink_linux_amd64.zip -o uplink_linux_amd64.zip && \ unzip -o uplink_linux_amd64.zip && \ install uplink /usr/local/bin/uplink + RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install symfony-cli diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 new file mode 100644 index 0000000..2fb94d0 --- /dev/null +++ b/Dockerfile.aarch64 @@ -0,0 +1,149 @@ +FROM arm64v8/ubuntu:22.04 + +RUN yes | unminimize + +RUN apt-get -y update && apt-get -y install locales + +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen + +ENV LANG=C.UTF-8 +ENV LANGUAGE=en_AU:en +ENV LC_CTYPE="C.UTF-8" +ENV LC_NUMERIC=en_US.UTF-8 +ENV LC_TIME=en_US.UTF-8 +ENV LC_COLLATE="C.UTF-8" +ENV LC_MONETARY=en_US.UTF-8 +ENV LC_MESSAGES="C.UTF-8" +ENV LC_PAPER=en_US.UTF-8 +ENV LC_NAME=en_US.UTF-8 +ENV LC_ADDRESS=en_US.UTF-8 +ENV LC_TELEPHONE=en_US.UTF-8 +ENV LC_MEASUREMENT=en_US.UTF-8 +ENV LC_IDENTIFICATION=en_US.UTF-8 +ENV TZ=Europe/Amsterdam + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ + man-db jq curl git pwgen build-essential libjansson-dev \ + libtiff-dev libgif-dev ffmpeg libffi-dev xutils-dev \ + libxpm-dev libpng-dev zlib1g-dev libgmp-dev autoconf pkg-config \ + p11-kit libp11-kit-dev nettle-dev libgnutls28-dev libtool \ + libncurses-dev bash cmake htop net-tools dnsutils libgtk-3-dev wget \ + libmagickwand-dev imagemagick libacl1-dev libxml2-dev + + +RUN wget https://ftp.gnu.org/gnu/emacs/emacs-28.1.tar.gz \ + -O /tmp/emacs.tar.gz + +WORKDIR /tmp/emacs + +RUN tar --strip-components=1 -xf /tmp/emacs.tar.gz + + +RUN ./configure + +RUN sed -i 's!static unsigned char sigsegv_stack\[SIGSTKSZ\]!static max_align_t sigsegv_stack\[(64 * 1024 + sizeof (max_align_t) - 1) / sizeof (max_align_t)\]!g' ./src/sysdep.c + +RUN make install + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ + libreadline8 bash-completion sudo tzdata + +RUN apt-get update && apt-get -y install \ + php8.1-memcached \ + php-redis \ + php8.1-bcmath \ + php8.1-bz2 \ + php8.1-cli \ + php8.1-common \ + php8.1-curl \ + php8.1-gmp \ + php8.1-intl \ + php-json \ + php8.1-mbstring \ + php8.1-mysql \ + php8.1-odbc \ + php8.1-opcache \ + php8.1-pgsql \ + php8.1-readline \ + php8.1-tidy \ + php8.1-xml \ + php8.1-xsl \ + php8.1-zip \ + php8.1-gd \ + php-bcmath \ + php-apcu \ + php-cli \ + php-imagick \ + composer \ + php-xdebug + + +run mkdir -p /opt/nodejs +RUN curl --location "https://nodejs.org/dist/v17.8.0/node-v17.8.0-linux-x64.tar.xz" | tar -Jxf - --strip-components=1 -C /opt/nodejs/ +# Make nodejs dir world-writable. This shouldn't be a problem as the container +# will, naturally only have a single user that has acces to the volume. +RUN chmod -R 777 /opt/nodejs + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ + ca-certificates curl gnupg lsb-release + +RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \ + && echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install docker-ce-cli apt-file +RUN apt-file update + +RUN curl -fsSL https://github.com/drone/drone-cli/releases/latest/download/drone_linux_arm64.tar.gz \ + | tar -xzf - -C /usr/bin/ + + +RUN curl --location "https://golang.org/dl/go1.18.linux-arm64.tar.gz" | tar -xzf - -C /usr/local/ +#RUN ln -s /usr/local/go/bin/* /usr/local/bin/ + +RUN GOPATH=/usr/local/gopkg /bin/bash -c 'for package in \ + golang.org/x/tools/cmd/...@latest \ + golang.org/x/tools/gopls@latest \ + github.com/dougm/goflymake@latest \ + golang.org/x/tools/cmd/goimports@latest; do \ + /usr/local/go/bin/go install "$package"; done' + +# RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install openjdk-17-jdk openjfx + +# RUN wget https://downloads.gradle-dn.com/distributions/gradle-7.4.2-bin.zip -O /tmp/gradle.zip +# RUN unzip -d /opt/ /tmp/gradle.zip +# RUN rm /tmp/gradle.zip +# RUN ln -sf /opt/gradle-7.4.2/bin/gradle /usr/bin/gradle + +# RUN mkdir -p /opt/maven +# RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O - |\ +# tar -C /opt/maven --strip-components=1 -xzf - +# RUN ln -s /opt/maven/bin/mvn /usr/bin/mvn + +# RUN wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -O /tmp/sonar-scanner.zip +# RUN unzip -d /opt/ /tmp/sonar-scanner.zip +# RUN rm /tmp/sonar-scanner.zip +# RUN ln -s /opt/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner /usr/bin/sonar-scanner + +# Protobuf +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install protobuf-compiler + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install html2text wkhtmltopdf pandoc ispell idutch irussian ienglish-common + +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-client + +RUN curl -L https://github.com/storj/storj/releases/latest/download/uplink_linux_arm64.zip -o uplink_linux_arm64.zip && \ + unzip -o uplink_linux_arm64.zip && \ + install uplink /usr/local/bin/uplink + +RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash +RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install symfony-cli + +ADD . /opt/workspace-repo +WORKDIR /opt/workspace-repo +RUN /usr/local/go/bin/go build . +RUN cp ./workspace /bin/workspace + +ENTRYPOINT [ "/bin/workspace", "entrypoint" ] diff --git a/emacs/init.el b/emacs/init.el index d3dccbb..f8ad975 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -487,12 +487,23 @@ OLD-FUNCTION must be the function that is being adviced." (require 'ido) (setq ido-enable-flex-matching t) (ido-everywhere 1) -;;(ido-vertical-mode 1) +(ido-vertical-mode 1) ;;; This is from ido-completing-read+ which made function/command completion garbage slow. ;;(ido-ubiquitous-mode 1) (ido-mode 1) +(defmacro hugot-get-function-object (sym-or-var) + `(or (when (symbolp ,sym-or-var) + (or (indirect-function ,sym-or-var) + (indirect-function (symbol-value ,sym-or-var)))) + ,sym-or-var)) + +(defun hugot-function= (f1 f2) + (eq + (hugot-get-function-object f1) + (hugot-get-function-object f2))) + (defun hugot-completing-read (prompt coll pred &rest args) "`completing-read-default' wrapper to use as `completing-read-function'. @@ -517,9 +528,11 @@ Enables ido for M-x and describe-function/describe-variable." (string-match "^Find file in" prompt)) (setq cr-function #'ido-completing-read cr-args `(,prompt ,(funcall coll "" pred t) ,pred ,@args)) - (pcase pred + (cond ;; Used for M-x (`read-extended-command') - ('commandp + ((or (hugot-function= 'commandp pred) + (hugot-function= 'read-extended-command-predicate pred) + (string-match "M-x" prompt)) (setq cr-function #'ido-completing-read cr-args `(,prompt ,(funcall coll "" pred t) ,pred ,@args))))))) (apply cr-function cr-args))) @@ -575,7 +588,7 @@ See `yank' for documentation of ARG." ;; END IDO (require 'hyperbole) -(eval-after-load 'kotl-mode '(require 'hugot-kotl-mode)) +;(eval-after-load 'kotl-mode '(require 'hugot-kotl-mode)) ;; Emoji support (set-fontset-font t 'symbol "Apple Color Emoji") @@ -594,8 +607,8 @@ See `yank' for documentation of ARG." (window-divider-mode) (scroll-bar-mode -1) (menu-bar-mode -1) - (set-frame-font "Hack 11" nil t) - (set-face-attribute 'default nil :height 110) + ;; (set-frame-font "Hack 11" nil t) + ;; (set-face-attribute 'default nil :height 110) (setq linum-format "%d ")) (hugot-set-appearance) diff --git a/main.go b/main.go index 54b46b4..8bbc28d 100644 --- a/main.go +++ b/main.go @@ -191,7 +191,11 @@ func Run(privileged bool, detach bool, mounts []string, command []string) error dockerBin, err := exec.LookPath("docker") if err != nil { - return err + if _, err := os.Stat("/usr/bin/docker"); !errors.Is(err, os.ErrNotExist) { + dockerBin = "/usr/bin/docker" + } else { + return err + } } dockerCommand := []string{