0

I'm relatively new to docker (at least to do more than run images others had built) and I'm stuck on this one. I'm building an app using Deno and trying to get it running in docker. my base image is the official deno image with Alpine, which uses an .sh as its entry point. The entry point script as defined in the official image is supposed to look at the first argument in the CMD (in this case "run") and if it's in a list (which it is), run it with the deno command. Instead I get an error.

the CMD

CMD run --allow-net --allow-read --lock=lock.json mod.ts

the error

/bin/sh: run: not found

when I hard code in the deno, it runs fine.

CMD deno run --allow-net --allow-read --lock=lock.json mod.ts

I can't figure why it's not working through the script as an entry point. What am I doing wrong?

docker-entry.sh

#!/bin/sh
set -e

if [ "$1" != "${1#-}" ]; then
    # if the first argument is an option like `--help` or `-h`
    exec deno "$@"
fi

case "$1" in
    bundle | cache | compile | completions | coverage | doc | eval | fmt | help | info | install | lint | lsp | repl | run | test | types | uninstall | upgrade | vendor )
    # if the first argument is a known deno command
    exec deno "$@";;
esac

exec "$@"

my Dockerfile

FROM denoland/deno:alpine-1.19.2

# The port that your application listens to.
EXPOSE MYPORTNUMBER

WORKDIR /app

# Prefer not to run as root.
USER deno

# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
COPY deps.ts .
RUN deno cache deps.ts

# These steps will be re-run upon each file change in your working directory:
ADD . .
# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache mod.ts

CMD run --allow-net --allow-read --lock=lock.json mod.ts

base image info here

Matt Flamm
  • 181
  • 1
  • 1
  • 14
  • is it possible that `run` is not in the list of `case "$1" in`? – Lei Yang Mar 30 '22 at 03:05
  • 1
    When you use a Dockerfile, you are creating a **new** image from the base Deno image. The [`ENTRYPOINT`](https://docs.docker.com/engine/reference/builder/#entrypoint) command is specific to the base image, so it does not apply to your derived image. – jsejcksn Mar 30 '22 at 03:47
  • @jsejcksn I'm not sure i understand what that means is needed. do I need to redefine a new entrypoint in my Dockerfile? How do I make it use the same script? The documentation for the base file gives an example Dockerfile https://hub.docker.com/r/denoland/deno that doesn't have a new entrypoint, so I'm clearly missing something. – Matt Flamm Mar 30 '22 at 23:09
  • @LeiYang in the copy of docker-entry.sh above which I took from the container it's in the list on line 9. – Matt Flamm Mar 30 '22 at 23:10
  • @MattFlamm It's not clear what you are trying to accomplish. If you want to run a `deno` program from a `CMD` entry, then you must invoke the `deno` binary (just like any other process). The purpose of that entrypoint script is to use the base image as a proxy for the deno binary via docker (not designed to be used as a utility for derived images). – jsejcksn Mar 31 '22 at 01:52
  • @jsejcksn do you mean entrypoint and cmd are not inheritable? – Lei Yang Mar 31 '22 at 15:25
  • @LeiYang See https://stackoverflow.com/q/42280792/438273 – jsejcksn Mar 31 '22 at 20:37

0 Answers0