diff --git a/Dockerfile b/Dockerfile index c78862d..cc350a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,6 +47,8 @@ RUN addgroup -g "${PGID}" zs && \ 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 / @@ -57,4 +59,4 @@ COPY .dockerfiles/entrypoint.sh /init ENTRYPOINT ["/init"] -CMD ["zs""] +CMD ["zs"", "serve", "0.0.0.0:8000", "/data"] diff --git a/main.go b/main.go index a281d39..9427bcb 100644 --- a/main.go +++ b/main.go @@ -329,13 +329,13 @@ func buildAll(ctx context.Context, watch bool) { } // 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 { @@ -386,10 +386,14 @@ func main() { 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":