adduser -D -H -G zs -h /var/empty -u "${PUID}" zs && \
mkdir -p /data && chown -R zs:zs /data
+EXPOSE 8000/tcp
+
VOLUME /data
WORKDIR /
ENTRYPOINT ["/init"]
-CMD ["zs""]
+CMD ["zs"", "serve", "0.0.0.0:8000", "/data"]
}
// serve runs a static web server and builds and continuously watches for changes to rebuild
-func serve(ctx context.Context, bind string) error {
- os.Mkdir(PUBDIR, 0755)
+func serve(ctx context.Context, bind, root string) error {
+ os.Mkdir(root, 0755)
svr, err := static.NewServer(
static.WithBind(bind),
static.WithDir(true),
- static.WithRoot(PUBDIR),
+ static.WithRoot(root),
static.WithSPA(true),
)
if err != nil {
buildAll(ctx, true)
case "serve":
bind := ":8000"
- if len(args) > 1 {
+ root := PUBDIR
+ if len(args) > 0 {
bind = args[0]
}
- if err := serve(ctx, bind); err != nil {
+ if len(args) > 1 {
+ root = args[1]
+ }
+ if err := serve(ctx, bind, root); err != nil {
fmt.Println("ERROR: " + err.Error())
}
case "var":