Deno Dockerfile Denon

3

我正在尝试使用 Docker 镜像 hayd/alpine-deno 来安装 Deno。基本版本(根据文档)运行良好,但我想添加一些文件监视器denon来增强开发过程。当我使用 docker-compose 构建容器时,出现了以下错误:

Building http-service
Step 1/10 : FROM hayd/alpine-deno:1.1.1
 ---> 265a525bcfa5
Step 2/10 : EXPOSE 3000
 ---> Using cache
 ---> f1dfcd77a566
Step 3/10 : WORKDIR /app
 ---> Using cache
 ---> df9c2dc916b4
Step 4/10 : USER deno
 ---> Using cache
 ---> c05fbfb4d1e7
Step 5/10 : COPY deps.ts .
 ---> Using cache
 ---> 250bf28f8b50
Step 6/10 : RUN deno cache deps.ts
 ---> Using cache
 ---> e32e9f80f625
Step 7/10 : ADD . .
 ---> e46e63e509ef
Step 8/10 : RUN deno cache src/main.ts
 ---> Running in c299b77ae595
Compile file:///app/src/main.ts
Removing intermediate container c299b77ae595
 ---> af94cc77fb42
Step 9/10 : RUN deno install --allow-read --allow-run --allow-write --allow-net -f --unstable https://deno.land/x/denon@v2.2.0/denon.ts
 ---> Running in 025fd5a81e9c
Download https://deno.land/x/denon@v2.2.0/denon.ts
Download https://deno.land/x/denon@v2.2.0/deps.ts
Download https://deno.land/x/denon@v2.2.0/src/watcher.ts
Download https://deno.land/x/denon@v2.2.0/src/runner.ts
Download https://deno.land/x/denon@v2.2.0/src/daemon.ts
Download https://deno.land/x/denon@v2.2.0/src/cli.ts
Download https://deno.land/x/denon@v2.2.0/src/config.ts
Download https://deno.land/x/denon@v2.2.0/src/args.ts
Download https://deno.land/x/denon@v2.2.0/src/log.ts
Download https://deno.land/std@0.57.0/log/mod.ts
Download https://deno.land/std@0.57.0/log/logger.ts
Download https://deno.land/std@0.57.0/log/levels.ts
Download https://deno.land/std@0.57.0/log/handlers.ts
Download https://deno.land/std@0.57.0/fmt/colors.ts
Download https://deno.land/std@0.57.0/fs/mod.ts
Download https://deno.land/std@0.57.0/encoding/yaml.ts
Download https://deno.land/std@0.57.0/path/mod.ts
Download https://deno.land/std@0.57.0/fs/read_json.ts
Download https://deno.land/std@0.57.0/fs/write_json.ts
Download https://deno.land/std@0.57.0/async/mod.ts
Download https://deno.land/std@0.57.0/permissions/mod.ts
Download https://deno.land/x/omelette/omelette.ts
Download https://deno.land/x/denon@v2.2.0/src/scripts.ts
Download https://deno.land/x/denon@v2.2.0/src/merge.ts
Download https://deno.land/std@0.53.0/node/events.ts
Download https://deno.land/std@0.53.0/path/mod.ts
Download https://deno.land/std@0.57.0/fs/exists.ts
Download https://deno.land/std@0.57.0/io/bufio.ts
Download https://deno.land/std@0.57.0/async/deferred.ts
Download https://deno.land/std@0.57.0/async/delay.ts
Download https://deno.land/std@0.57.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.57.0/fs/empty_dir.ts
Download https://deno.land/std@0.57.0/fs/ensure_dir.ts
Download https://deno.land/std@0.57.0/fs/ensure_file.ts
Download https://deno.land/std@0.57.0/fs/ensure_link.ts
Download https://deno.land/std@0.57.0/fs/ensure_symlink.ts
Download https://deno.land/std@0.57.0/fs/expand_glob.ts
Download https://deno.land/std@0.57.0/fs/move.ts
Download https://deno.land/std@0.57.0/fs/copy.ts
Download https://deno.land/std@0.57.0/fs/read_file_str.ts
Download https://deno.land/std@0.57.0/fs/write_file_str.ts
Download https://deno.land/std@0.57.0/fs/walk.ts
Download https://deno.land/std@0.57.0/fs/eol.ts
Download https://deno.land/std@0.53.0/node/util.ts
Download https://deno.land/std@0.53.0/testing/asserts.ts
Download https://deno.land/std@0.57.0/_util/assert.ts
Download https://deno.land/std@0.53.0/path/win32.ts
Download https://deno.land/std@0.53.0/path/posix.ts
Download https://deno.land/std@0.53.0/path/common.ts
Download https://deno.land/std@0.53.0/path/separator.ts
Download https://deno.land/std@0.53.0/path/interface.ts
Download https://deno.land/std@0.53.0/path/glob.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/parse.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/stringify.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema/mod.ts
Download https://deno.land/std@0.57.0/io/util.ts
Download https://deno.land/std@0.57.0/fs/_util.ts
Download https://deno.land/std@0.57.0/path/_constants.ts
Download https://deno.land/std@0.57.0/path/win32.ts
Download https://deno.land/std@0.57.0/path/posix.ts
Download https://deno.land/std@0.57.0/path/common.ts
Download https://deno.land/std@0.57.0/path/separator.ts
Download https://deno.land/std@0.57.0/path/_interface.ts
Download https://deno.land/std@0.57.0/path/glob.ts
Download https://deno.land/std@0.53.0/node/_util/_util_callbackify.ts
Download https://deno.land/std@0.53.0/node/_utils.ts
Download https://deno.land/std@0.53.0/path/_globrex.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/error.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/utils.ts
Download https://deno.land/std@0.53.0/path/_constants.ts
Download https://deno.land/std@0.53.0/path/_util.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/loader/loader.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/loader/loader_state.ts
Download https://deno.land/std@0.53.0/fmt/colors.ts
Download https://deno.land/std@0.53.0/testing/diff.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema/core.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema/default.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema/failsafe.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/schema/json.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/dumper/dumper.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/dumper/dumper_state.ts
Download https://deno.land/std@0.57.0/path/_util.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/mark.ts
Download https://deno.land/std@0.57.0/path/_globrex.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/state.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/mod.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/binary.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/bool.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/float.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/int.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/map.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/merge.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/nil.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/omap.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/pairs.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/seq.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/set.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/str.ts
Download https://deno.land/std@0.57.0/encoding/_yaml/type/timestamp.ts
Compile https://deno.land/x/denon@v2.2.0/denon.ts
 Successfully installed denon
/home/deno/.deno/bin/denon
ℹ️  Add /home/deno/.deno/bin to PATH
    export PATH="/home/deno/.deno/bin:$PATH"
Removing intermediate container 025fd5a81e9c
 ---> e06770d0972f
Step 10/10 : CMD ["denon", "run", "--allow-net", "src/main.ts"]
 ---> Running in 73874479e0d1
Removing intermediate container 73874479e0d1
 ---> 6331bb4fba26

Successfully built 6331bb4fba26
Successfully tagged stocks_http-service:latest
Recreating stocks_http-service_1 ... done
Attaching to stocks_http-service_1
http-service_1  | error: Found argument 'denon' which wasn't expected, or isn't valid in this context
http-service_1  | 
http-service_1  | USAGE:
http-service_1  |     deno [OPTIONS] [SUBCOMMAND]
http-service_1  | 
http-service_1  | For more information try --help
stocks_http-service_1 exited with code 1

我的Dockerfile:

FROM hayd/alpine-deno:1.1.1
EXPOSE 3000
WORKDIR /app
USER deno
COPY deps.ts .
RUN deno cache deps.ts
ADD . .
RUN deno cache src/main.ts
RUN deno install --allow-read --allow-run --allow-write --allow-net -f --unstable https://deno.land/x/denon@v2.2.0/denon.ts
CMD ["denon", "run", "--allow-net", "src/main.ts"]
1个回答

6

ENTRYPOINT 是指 image 文件的入口点,因此您要运行的命令是:

deno denon run --allow-net src/main.ts

对于那个Docker镜像,您需要更改ENTRYPOINT

ENTRYPOINT ["/home/deno/.deno/bin/denon"]
CMD ["run", "--allow-net", "src/main.ts"]

尝试使用你的解决方案在我的dockerfile中使用denon,但是不幸地它返回了错误信息: error: Permission denied (os error 13) ERROR: Service 'deno-container' failed to build: The command '/bin/sh -c deno install --allow-read --allow-run --allow-write --allow-net -f --unstable https://deno.land/x/denon@2.4.6/denon.ts' returned a non-zero code: 1有什么想法是为什么会出现这种情况? - Antonio Dell
@AntonioDell 这是因为 deno 用户无法进行 deno install,所以您可以在更改当前用户(即:USER deno)之前,在 DockerFile 中移动您的安装命令 RUN - Thomas Di G

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接