diff --git a/Containerfile b/Containerfile index edd191c..ede100e 100644 --- a/Containerfile +++ b/Containerfile @@ -1,12 +1,7 @@ -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 +FROM docker.io/library/debian:11 +RUN apt update && apt upgrade -y && apt install -y build-essential m4 libssl-dev libmagic-dev libuuid1 uuid-dev liblmdb0 liblmdb-dev git libreadline-dev autoconf automake libtool libz-dev libvips ncurses-bin wget unzip openssl # install luaver and install luarocks packages: -RUN ln -s /usr/lib/libvips.so.42 /usr/lib/libvips.so \ +RUN ln -s /usr/lib/x86_64-linux-gnu/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", "\ @@ -31,7 +26,8 @@ RUN ["bash", "-c", "\ && luarocks install magic \ && luarocks install lightningmdb \ && luarocks install lua_uuid \ - && luarocks install lua-vips"] + && luarocks install lua-vips \ + && luarocks install debugger"] 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 9d4d5ff..1e14062 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # piazzaoptical.com -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. +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, as do lack of features. ## To use: @@ -22,4 +22,13 @@ Finally, run a container based on this image (I chose to expose the container th ```bash podman run -it --rm -p 8004:8000 -v ${PWD}:/app localhost/piazzaoptical.com -``` \ No newline at end of file +``` + +## Explore: + +Sample credentials: + +* Username `admin`, Password `admin` +* Username `guest`, Password `buginoo` + +One can also not sign-in at all, rather "Apply for an Account", then sign-in as `admin` and accept the application, logout, and sign-in as the new account. \ No newline at end of file diff --git a/server/initialize-piazza-db.lua b/server/initialize-piazza-db.lua index 840628a..a95cde1 100644 --- a/server/initialize-piazza-db.lua +++ b/server/initialize-piazza-db.lua @@ -7,13 +7,6 @@ local item = require('./models/item') user.setdb(db) item.setdb(db) -user.new({ - username = 'brian', - password = 'buginoO1$', - firstname = 'Brian', - lastname = 'Sakal', - is_admin = true - }) user.new({ username = 'guest', password = 'buginoo', @@ -21,9 +14,9 @@ user.new({ lastname = 'Beast' }) user.new({ - username = 'w', - password = 'w', - firstname = 'Test', + username = 'admin', + password = 'admin', + firstname = 'Demo Admin', lastname = 'User', is_admin = true }) diff --git a/server/piazza-lmdb.lua b/server/piazza-lmdb.lua index 291669a..ddfe930 100644 --- a/server/piazza-lmdb.lua +++ b/server/piazza-lmdb.lua @@ -7,6 +7,7 @@ end}) --local binser = require'binser' local bitser = require'bitser/bitser' +bitser.includeMetatables(false) local lrandom = require'random' -- 'lrandom' luarocks package local lrandom_sequence = lrandom.new(os.time()) diff --git a/server/piazza.lmdb b/server/piazza.lmdb new file mode 100644 index 0000000..4a8b474 Binary files /dev/null and b/server/piazza.lmdb differ diff --git a/server/server.lua b/server/server.lua index bf46850..a83d378 100644 --- a/server/server.lua +++ b/server/server.lua @@ -17,6 +17,9 @@ local lpeg = require "lpeg" local uri_patts = require "lpeg_patterns.uri" local cjson = require "cjson" local mimetypes = require "mimetypes" + +local dbg = require("debugger") + local api = require './piazza-api-lmdb' local replyJSON = function(t, stream) @@ -261,6 +264,7 @@ local function reply(myserver, stream) function(err) print('ERROR: ', err) print(debug.traceback()) + -- dbg() end) end