Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Created August 19, 2018 21:15
Show Gist options
  • Save djfdyuruiry/b8df2d84220e86d4fc3edb55d9457c41 to your computer and use it in GitHub Desktop.
Save djfdyuruiry/b8df2d84220e86d4fc3edb55d9457c41 to your computer and use it in GitHub Desktop.
Docker container which provides a Lua interpreter with access to luarocks; uses alpine linux as the base image
#!/usr/bin/env ash
read -r -d '' PROMPT_LUA << EOM
_PROMPT = '[alpine-lua]# '
luarocks =
{
install = function(pkg)
return os.execute('luarocks install ' .. pkg)
end
}
print('> Call luarocks.install() to add packages, e.x. luarocks.install(\"luasocket\")')
EOM
lua -e "${PROMPT_LUA}" -i "$@"
####################################################################################################
# apline-lua docker env: run with `docker build . -t alpine-lua && docker run -it --rm alpine-lua` #
####################################################################################################
FROM alpine
ARG LUA_VER="5.3.5"
ARG LUA_ROCKS_VER="3.0.0"
# required packages to build lua and run luarocks
RUN apk add libc-dev readline readline-dev gcc make wget
# install lua
RUN cd /tmp \
&& wget https://www.lua.org/ftp/lua-${LUA_VER}.tar.gz \
&& tar zxf lua-${LUA_VER}.tar.gz \
&& cd lua-${LUA_VER} \
&& make linux install \
&& cd /tmp \
&& rm -rf /tmp/*
# install luarocks
RUN cd /tmp \
&& wget https://luarocks.org/releases/luarocks-${LUA_ROCKS_VER}.tar.gz \
&& tar zxf luarocks-${LUA_ROCKS_VER}.tar.gz \
&& cd luarocks-${LUA_ROCKS_VER} \
&& ./configure \
&& make build \
&& make install \
&& cd /tmp \
&& rm -rf /tmp/*
COPY md5sum /usr/bin
COPY alpine-lua /usr/bin
ENTRYPOINT [ "alpine-lua" ]
#!/usr/bin/env ash
################################################################
# Workaround for lack of version flag in busybox md5sum applet #
################################################################
if [ "$1" = "--version" ]; then
busybox --help || true # ignore non-zero exit code
exit 0 # emulate md5sum's '--version' exit code
fi
busybox md5sum "$@" # pass all arguments to busybox applet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment