git.s-ol.nu mmm / ca96a23
realtime server Dockerfile s-ol 3 years ago
5 changed file(s) with 26 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
0 FROM nickblah/lua:5.3-luarocks-stretch AS build-env
1 RUN echo "deb http://ppa.launchpad.net/jonathonf/tup/ubuntu xenial main" >/etc/apt/sources.list.d/tup.list
2 RUN apt-get update
3 RUN apt-get install -y --allow-unauthenticated build-essential tup sassc libmarkdown2-dev
0 FROM nickblah/lua:5.3-luarocks-stretch
1
2 RUN echo "deb http://ppa.launchpad.net/jonathonf/tup/ubuntu xenial main" \
3 >/etc/apt/sources.list.d/tup.list
4 RUN apt-get update && \
5 apt-get install -y --allow-unauthenticated \
6 build-essential m4 tup sassc \
7 libmarkdown2-dev libsqlite3-dev libssl-dev
8 RUN luarocks install discount DISCOUNT_INCDIR=/usr/include/x86_64-linux-gnu
49 RUN luarocks install moonscript
5 RUN luarocks install discount DISCOUNT_INCDIR=/usr/include/x86_64-linux-gnu
6 COPY . /build
7 RUN cd /build && tup init && tup generate --config tup.docker.config build.sh && ./build.sh
10 RUN luarocks install sqlite3
11 RUN luarocks install http
812
9 FROM nginx:alpine
10 COPY --from=build-env /build/root /usr/share/nginx/html
11 RUN chmod 555 -R /usr/share/nginx/html
13 COPY . /code
14 WORKDIR /code
15 RUN tup init && tup generate --config tup.docker.config build-static.sh && ./build-static.sh
16
17 EXPOSE 8000
18 ENTRYPOINT ["moon", "build/server.moon", "/db.sqlite3", "0.0.0.0", "8000"]
1313
1414 -- usage:
1515 -- moon import.moon <root> [output.sqlite3]
16 { root, output } = arg
16 { root, file } = arg
1717
1818 assert root, "please specify the root directory"
1919
2929
3030 key, value
3131
32 with SQLStore name: output, verbose: true
32 with SQLStore :file, verbose: true
3333 import_fileder = (fileder, dirpath) ->
3434 for file in lfs.dir dirpath
3535 continue if '.' == file\sub 1, 1
2020 export BROWSER, STATIC
2121 STATIC = true
2222
23 tree = load_tree SQLStore :name
23 tree = load_tree SQLStore :file
2424 tree = tree\walk startpath if startpath
2525
2626 for fileder in coroutine.wrap tree\iterate
162162 print msg
163163
164164 -- usage:
165 -- moon server.moon [db.sqlite3]
166 { file } = arg
165 -- moon server.moon [db.sqlite3] [host] [port]
166 { file, host, port } = arg
167167
168168 tree = load_tree SQLStore :file
169 server = Server tree
169 server = Server tree, :host, port: port and tonumber port
170170 server\listen!
11
22 class SQLStore
33 new: (opts = {}) =>
4 opts.name or= 'db.sqlite3'
4 opts.file or= 'db.sqlite3'
55 opts.verbose or= false
66 opts.memory or= false
77
1212 @log "opening in-memory DB..."
1313 @db = sqlite.open_memory!
1414 else
15 @log "opening '#{opts.name}'..."
16 @db = sqlite.open opts.name
15 @log "opening '#{opts.file}'..."
16 @db = sqlite.open opts.file
1717
1818 assert @db\exec [[
1919 PRAGMA foreign_keys = ON;