diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..edd191c --- /dev/null +++ b/Containerfile @@ -0,0 +1,37 @@ +FROM docker.io/library/alpine:3.14 +# we need bash for luaver: +RUN apk add --no-cache bash && echo "" > /root/.ash_history +RUN sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd +ENV LC_ALL=en_US.UTF-8 +# requirements for various luarocks packages: +RUN apk add --no-cache build-base bsd-compat-headers m4 openssl-dev libmagic libuuid lmdb lmdb-dev git readline-dev autoconf automake libtool zlib-dev vips ncurses wget unzip openssl util-linux-dev +# install luaver and install luarocks packages: +RUN ln -s /usr/lib/libvips.so.42 /usr/lib/libvips.so \ + && git config --global url."https://".insteadOf git:// \ + && git clone https://git.sakal.us/brian/luaver.git ~/.luaver +RUN ["bash", "-c", "\ + { . ~/.luaver/luaver; } \ + ; { yes | luaver install 5.1.5; } \ + && { yes | luaver install-luajit 2.0.5; } \ + && luaver use 5.1.5 && luaver set-default 5.1.5 \ + && luaver use-luajit 2.0.5 && luaver set-default-luajit 2.0.5 \ + && { yes | luaver install-luarocks 3.8.0; } \ + && luaver use-luarocks 3.8.0 && luaver set-default-luarocks 3.8.0 \ + && luarocks install luarocks-fetch-gitrec \ + && luarocks install compat53 \ + && luarocks install cqueues \ + && luarocks install lpeg \ + && luarocks install lpeg_patterns \ + && luarocks install luafilesystem \ + && luarocks install http \ + && luarocks install lua-cjson \ + && luarocks install mimetypes \ + && luarocks install lrandom \ + && luarocks install luaprompt \ + && luarocks install magic \ + && luarocks install lightningmdb \ + && luarocks install lua_uuid \ + && luarocks install lua-vips"] +WORKDIR /app/server +EXPOSE 8000 +CMD ["bash", "-c", "{ . ~/.luaver/luaver; } ; luajit ./server.lua"] \ No newline at end of file diff --git a/README.md b/README.md index 004456a..9d4d5ff 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,25 @@ # piazzaoptical.com -Code for what once was piazzaoptical.com. Backend and frontend. +Code for what once was piazzaoptical.com. Backend and frontend. Unfortunately, I lost the code of the final product; this is the code of a very early stage, and errors abound. ## To use: -```bash -podman run -it --rm -p 8000:8000 docker.io/library/alpine:3.14 # v3.15 can't seem to work with package "bsd-compat-headers" -``` - -Then within the container: +First clone this repo, and the `bitser` repo that's included as a submodule: ```bash -apk add --no-cache build-base bsd-compat-headers m4 openssl-dev libmagic libuuid lmdb lmdb-dev git readline-dev autoconf automake libtool zlib-dev vips ncurses wget unzip openssl util-linux-dev bash -ln -s /usr/lib/libvips.so.42 /usr/lib/libvips.so -git config --global url."https://".insteadOf git:// # for luarocks pulling from github; it uses unencrypted -git clone https://git.sakal.us/brian/luaver.git ~/.luaver -bash +git clone https://git.sakal.us/brian/piazzaoptical.com +cd piazzaoptical.com +git submodule update --init --recursive # for bitser; installed as git submodule ``` -Then in `bash` shell (not the default `ash`): +Build the podman image based on the Containerfile: ```bash -. ~/.luaver/luaver -yes | luaver install 5.1.5 -yes | luaver install-luajit 2.0.5 -luaver use 5.1.5 -luaver use-luajit 2.0.5 -yes | luaver install-luarocks 3.8.0 -luaver use-luarocks 3.8.0 -luarocks install luarocks-fetch-gitrec # for magic -luarocks install compat53 -luarocks install cqueues -luarocks install lpeg -luarocks install lpeg_patterns -luarocks install luafilesystem -luarocks install http -luarocks install lua-cjson -luarocks install mimetypes -luarocks install lrandom -luarocks install luaprompt -luarocks install magic -luarocks install lightningmdb -luarocks install lua_uuid -luarocks install lua-vips +podman build --tag piazzaoptical.com . ``` -Finally: +Finally, run a container based on this image (I chose to expose the container through port 8004 on the host): ```bash -git clone https://git.sakal.us/brian/piazzaoptical.com -cd piazzaoptical.com -git submodule update --init --recursive # for bitser; installed as git submodule -cd server -luajit ./server.lua +podman run -it --rm -p 8004:8000 -v ${PWD}:/app localhost/piazzaoptical.com ``` \ No newline at end of file diff --git a/server/server.lua b/server/server.lua index 7f51f96..bf46850 100644 --- a/server/server.lua +++ b/server/server.lua @@ -265,7 +265,8 @@ local function reply(myserver, stream) end local myserver = assert(http_server.listen { - host = "localhost"; + --host = "localhost"; + host = "0.0.0.0"; port = port; max_concurrent = 100; onstream = reply;