mirror of
https://git.mills.io/prologic/zs.git
synced 2024-11-08 03:07:57 -05:00
Add support for specifying root driectory for zs serve
This commit is contained in:
parent
339de0457c
commit
d980980a0b
@ -47,6 +47,8 @@ RUN addgroup -g "${PGID}" zs && \
|
|||||||
adduser -D -H -G zs -h /var/empty -u "${PUID}" zs && \
|
adduser -D -H -G zs -h /var/empty -u "${PUID}" zs && \
|
||||||
mkdir -p /data && chown -R zs:zs /data
|
mkdir -p /data && chown -R zs:zs /data
|
||||||
|
|
||||||
|
EXPOSE 8000/tcp
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
@ -57,4 +59,4 @@ COPY .dockerfiles/entrypoint.sh /init
|
|||||||
|
|
||||||
ENTRYPOINT ["/init"]
|
ENTRYPOINT ["/init"]
|
||||||
|
|
||||||
CMD ["zs""]
|
CMD ["zs"", "serve", "0.0.0.0:8000", "/data"]
|
||||||
|
14
main.go
14
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
|
// serve runs a static web server and builds and continuously watches for changes to rebuild
|
||||||
func serve(ctx context.Context, bind string) error {
|
func serve(ctx context.Context, bind, root string) error {
|
||||||
os.Mkdir(PUBDIR, 0755)
|
os.Mkdir(root, 0755)
|
||||||
|
|
||||||
svr, err := static.NewServer(
|
svr, err := static.NewServer(
|
||||||
static.WithBind(bind),
|
static.WithBind(bind),
|
||||||
static.WithDir(true),
|
static.WithDir(true),
|
||||||
static.WithRoot(PUBDIR),
|
static.WithRoot(root),
|
||||||
static.WithSPA(true),
|
static.WithSPA(true),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -386,10 +386,14 @@ func main() {
|
|||||||
buildAll(ctx, true)
|
buildAll(ctx, true)
|
||||||
case "serve":
|
case "serve":
|
||||||
bind := ":8000"
|
bind := ":8000"
|
||||||
if len(args) > 1 {
|
root := PUBDIR
|
||||||
|
if len(args) > 0 {
|
||||||
bind = 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())
|
fmt.Println("ERROR: " + err.Error())
|
||||||
}
|
}
|
||||||
case "var":
|
case "var":
|
||||||
|
Loading…
Reference in New Issue
Block a user