From 5153adfe2090ae80138addf3749750cd096fe1a2 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 29 Feb 2024 16:31:41 +0100 Subject: [PATCH 1/2] Update and optimize images --- lua-clib/Dockerfile | 164 +++++++++++++++++++++++++-------------- node-script/Dockerfile | 33 ++++++++ python-script/Dockerfile | 34 ++++++++ ruby-script/Dockerfile | 26 +++++++ 4 files changed, 199 insertions(+), 58 deletions(-) create mode 100644 node-script/Dockerfile create mode 100644 python-script/Dockerfile create mode 100644 ruby-script/Dockerfile diff --git a/lua-clib/Dockerfile b/lua-clib/Dockerfile index de33f68..af788cb 100644 --- a/lua-clib/Dockerfile +++ b/lua-clib/Dockerfile @@ -1,10 +1,102 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim as builder ENV DEBIAN_FRONTEND=noninteractive -RUN set -e; \ +WORKDIR /build + +RUN --mount=type=cache,target=/var/cache/apt,id=builder-apt \ + set -e; \ apt-get update; \ - apt-get install -y --no-install-recommends \ + apt-get install -y --no-install-recommends --no-install-suggests \ + ca-certificates \ + cmake \ + gcc \ + g++ \ + libc-dev \ + libreadline-dev \ + make \ + stow \ + unzip \ + wget \ + xz-utils; + +ARG LUA_5_1_VERSION=5.1.5 +ADD http://www.lua.org/ftp/lua-${LUA_5_1_VERSION}.tar.gz /build/lua-5.1.tar.gz + +RUN set -e; \ + tar -xzf /build/lua-5.1.tar.gz; \ + cd lua-${LUA_5_1_VERSION}/src; \ + make -j $(nproc) all MYCFLAGS="-DLUA_USE_LINUX -fPIC" MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"; \ + cd ..; \ + make INSTALL_TOP=/usr/local/stow/lua5.1 install + +ARG LUA_5_2_VERSION=5.2.4 +ADD http://www.lua.org/ftp/lua-${LUA_5_2_VERSION}.tar.gz /build/lua-5.2.tar.gz + +RUN set -e; \ + tar -xzf /build/lua-5.2.tar.gz; \ + cd lua-${LUA_5_2_VERSION}/src; \ + make -j $(nproc) linux MYCFLAGS="-fPIC"; \ + cd ..; \ + make INSTALL_TOP=/usr/local/stow/lua5.2 install + +ARG LUA_5_3_VERSION=5.3.6 +ADD http://www.lua.org/ftp/lua-${LUA_5_3_VERSION}.tar.gz /build/lua-5.3.tar.gz + +RUN set -e; \ + tar -xzf /build/lua-5.3.tar.gz; \ + cd lua-${LUA_5_3_VERSION}/src; \ + make -j $(nproc) linux MYCFLAGS="-fPIC"; \ + cd ..; \ + make INSTALL_TOP=/usr/local/stow/lua5.3 install + +ARG LUA_5_4_VERSION=5.4.4 +ADD http://www.lua.org/ftp/lua-${LUA_5_4_VERSION}.tar.gz /build/lua-5.4.tar.gz + +RUN set -e; \ + tar -xzf /build/lua-5.4.tar.gz; \ + cd lua-${LUA_5_4_VERSION}/src; \ + make -j $(nproc) linux MYCFLAGS="-fPIC"; \ + cd ..; \ + make INSTALL_TOP=/usr/local/stow/lua5.4 install + +ARG LUAROCKS_VERSION=3.10.0 +ADD https://luarocks.org/releases/luarocks-${LUAROCKS_VERSION}.tar.gz /build/luarocks.tar.gz + +RUN set -e; \ + tar -xzf /build/luarocks.tar.gz; \ + cd luarocks-${LUAROCKS_VERSION}; \ + ./configure --prefix=/usr --with-lua=/usr/local/stow/lua5.4; \ + make -j $(nproc); \ + make install + +ARG DART_SASS_VERSION=1.71.1 +ADD https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz /build/sass.tar.gz + +RUN tar -xzf /build/sass.tar.gz -C /usr/local/bin --strip-components=1 dart-sass/sass + +ARG NODE_VERSION=20.11.1 +ADD https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz /build/node.tar.xz + +RUN set -e; \ + mkdir -p /usr/local/stow/node; \ + tar -xJf /build/node.tar.xz -C /usr/local/stow/node --strip-components=1 \ + --wildcards --no-wildcards-match-slash '*/bin/' '*/include/' '*/lib/'; \ + stow -d /usr/local/stow -t /usr/local -S node + +RUN --mount=type=cache,target=/var/cache/luarocks \ + set -e; \ + luarocks install ldoc; \ + luarocks install lua-discount + +FROM debian:bookworm-slim + +ENV DEBIAN_FRONTEND=noninteractive + +RUN --mount=type=cache,target=/var/cache/apt,id=apt \ + set -e; \ + apt-get update; \ + apt-get install -y --no-install-recommends --no-install-suggests \ ca-certificates \ cmake \ curl \ @@ -13,64 +105,20 @@ RUN set -e; \ libc-dev \ libreadline-dev \ make \ - stow \ sudo \ unzip \ - wget \ - xz-utils; \ - rm -rf /var/cache/apt/* + wget; \ + apt-get remove --auto-remove vim; \ + rm -rf \ + /usr/share/cmake-*/Help \ + /var/lib/apt/lists/* \ + /var/log/* \ + /usr/local/share/doc/* \ + /usr/local/share/man/* \ + /usr/share/doc/* \ + /usr/share/man/* -WORKDIR /build - -RUN set -e; \ - wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz; \ - mkdir -p /usr/local/stow/node; \ - tar -xJf node-v16.17.0-linux-x64.tar.xz -C /usr/local/stow/node --strip-components=1; \ - stow -d /usr/local/stow -t /usr/local -S node; \ - wget http://www.lua.org/ftp/lua-5.1.5.tar.gz; \ - tar -xzf lua-5.1.5.tar.gz; \ - cd lua-5.1.5/src; \ - make -j $(nproc) all MYCFLAGS="-DLUA_USE_LINUX -fPIC" MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"; \ - cd ..; \ - make INSTALL_TOP=/usr/local/stow/lua5.1 install; \ - cd /build; \ - wget http://www.lua.org/ftp/lua-5.2.4.tar.gz; \ - tar -xzf lua-5.2.4.tar.gz; \ - cd lua-5.2.4/src; \ - make -j $(nproc) linux MYCFLAGS="-fPIC"; \ - cd ..; \ - make INSTALL_TOP=/usr/local/stow/lua5.2 install; \ - cd /build; \ - wget http://www.lua.org/ftp/lua-5.3.6.tar.gz; \ - tar -xzf lua-5.3.6.tar.gz; \ - cd lua-5.3.6/src; \ - make -j $(nproc) linux MYCFLAGS="-fPIC"; \ - cd ..; \ - make INSTALL_TOP=/usr/local/stow/lua5.3 install; \ - cd /build; \ - wget http://www.lua.org/ftp/lua-5.4.4.tar.gz; \ - tar -xzf lua-5.4.4.tar.gz; \ - cd lua-5.4.4/src; \ - make -j $(nproc) linux MYCFLAGS="-fPIC"; \ - cd ..; \ - make INSTALL_TOP=/usr/local/stow/lua5.4 install; \ - cd /build; \ - wget https://luarocks.org/releases/luarocks-3.9.1.tar.gz; \ - tar -xzf luarocks-3.9.1.tar.gz; \ - cd luarocks-3.9.1; \ - ./configure --prefix=/usr --with-lua=/usr/local/stow/lua5.4; \ - make -j $(nproc); \ - make install; \ - cd /build; \ - wget https://github.com/sass/dart-sass/releases/download/1.54.4/dart-sass-1.54.4-linux-x64.tar.gz; \ - tar -xzf dart-sass-1.54.4-linux-x64.tar.gz; \ - mv dart-sass/sass /usr/bin/sass; \ - cd /; \ - rm -r /build - -RUN set -e; \ - luarocks install ldoc; \ - luarocks install lua-discount +COPY --from=builder /usr/local /usr/local WORKDIR / diff --git a/node-script/Dockerfile b/node-script/Dockerfile new file mode 100644 index 0000000..6a8a80f --- /dev/null +++ b/node-script/Dockerfile @@ -0,0 +1,33 @@ +FROM node:lts-slim + +LABEL version=1.0.0 + +RUN rm -r \ + /var/log/* \ + /usr/local/share/doc/* \ + /usr/local/share/man/* \ + /usr/share/doc/* \ + /usr/share/man/* \ + /tmp/* + +# No need for root access for a script runner +RUN useradd -m -d /home/runner -s /bin/bash runner +WORKDIR /home/runner +USER runner + +ENV NODE_ENV=production +ENV NPM_CONFIG_PREFIX=/home/runner/.npm-global +ENV PATH=/home/runner/.npm-global/bin:$PATH + +RUN set -e; \ + npm install --global --audit=false \ + npm@10.5.0 \ + bluebird \ + lodash \ + moment \ + shelljs \ + js-yaml \ + got; \ + rm -r \ + /home/runner/.npm/_cacache \ + /home/runner/.npm/_logs diff --git a/python-script/Dockerfile b/python-script/Dockerfile new file mode 100644 index 0000000..db810a7 --- /dev/null +++ b/python-script/Dockerfile @@ -0,0 +1,34 @@ +FROM python:3-slim-bookworm + +LABEL version=1.1.0 + +RUN set -e; \ + apt-get update -q; \ + apt-get install -qy --no-install-recommends --no-install-suggests \ + bc \ + curl \ + dash \ + gettext \ + git \ + jq; \ + apt-get clean; \ + rm -rf \ + /var/cache/apt/* \ + /var/lib/apt/lists/* \ + /var/log/* \ + /usr/local/share/doc/* \ + /usr/local/share/man/* \ + /usr/share/doc/* \ + /usr/share/man/* + +# No need for root access for a script runner +RUN useradd -m -d /home/runner -s /bin/bash runner +WORKDIR /home/runner +USER runner + +ENV PATH=/home/runner/.local/bin:$PATH + +RUN set -e; \ + pip install --upgrade pip; \ + pip install --user numpy httpie giteapy docker xq yp spotify requests; \ + rm -r /home/runner/.cache diff --git a/ruby-script/Dockerfile b/ruby-script/Dockerfile new file mode 100644 index 0000000..078eb82 --- /dev/null +++ b/ruby-script/Dockerfile @@ -0,0 +1,26 @@ +FROM ruby:3.1-slim-bookworm + +LABEL version=1.1.0 + +ENV DEBIAN_FRONTEND=noninteractive +RUN --mount=type=cache,target=/var/cache/apt,id=apt \ + set -e; \ + apt-get update; \ + apt-get install -y --no-install-recommends --no-install-suggests \ + gcc \ + make; \ + apt-get clean; \ + rm -rf \ + /var/lib/apt/lists/* \ + /var/log/* \ + /usr/share/doc/* \ + /usr/share/man/* + +# No need for root access for a script runner +RUN useradd -m -d /home/runner -s /bin/bash runner +WORKDIR /home/runner +USER runner + +ENV PATH=/home/runner/.local/share/gem/ruby/3.1.0/bin:$PATH + +RUN gem install --user_install json docker-api From be96349cb2b7eba1e7dd0ea96f05f59e07250bbd Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 29 Feb 2024 16:32:19 +0100 Subject: [PATCH 2/2] Add rust builder images --- rust-linux/Dockerfile | 1 + rust-windows/Dockerfile | 13 +++++++++++++ rust-windows/config.toml | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 rust-linux/Dockerfile create mode 100644 rust-windows/Dockerfile create mode 100644 rust-windows/config.toml diff --git a/rust-linux/Dockerfile b/rust-linux/Dockerfile new file mode 100644 index 0000000..2e9265f --- /dev/null +++ b/rust-linux/Dockerfile @@ -0,0 +1 @@ +FROM rust:slim diff --git a/rust-windows/Dockerfile b/rust-windows/Dockerfile new file mode 100644 index 0000000..0507946 --- /dev/null +++ b/rust-windows/Dockerfile @@ -0,0 +1,13 @@ +FROM rust-linux + +RUN set -e; \ + apt-get update; \ + apt-get install -y --no-install-recommends g++-mingw-w64-x86-64; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +RUN set -e; \ + rustup target add x86_64-pc-windows-gnu; \ + rustup toolchain install --force-non-host stable-x86_64-pc-windows-gnu + +COPY config.toml $CARGO_HOME/config.toml diff --git a/rust-windows/config.toml b/rust-windows/config.toml new file mode 100644 index 0000000..ba54493 --- /dev/null +++ b/rust-windows/config.toml @@ -0,0 +1,2 @@ +[build] +target = "x86_64-pc-windows-gnu"