Sign inSign up

hayd/distroless-deno

By hayd

Updated over 5 years ago

Deno on distroless

Image
0

1.7K

hayd/distroless-deno repository overview

ANNOUNCEMENT

hayd/deno docker images have now been moved into the official denoland repository https://hub.docker.com/r/denoland/deno.

These images will no longer be updated. Please update your dockerfiles to use denoland/deno:distroless.



Distroless Deno

https://github.com/hayd/deno-docker

Run locally:

To run main.ts from your working directory:

$ docker run -it --init -p 1993:1993 -v $PWD:/app hayd/distroless-deno:1.6.2 run --allow-net /app/main.ts

Here, -p 1993:1993 maps port 1993 on the container to 1993 on the host, -v $PWD:/app mounts the host working directory to /app on the container, and run --allow-net /app/main.ts is passed to deno on the container.

As a Dockerfile

FROM hayd/distroless-deno:1.6.2

# The port that your application listens to.
EXPOSE 1993

WORKDIR /app

# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally fetch 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", "main.ts"]

# Optionally prefer not to run as root.
# USER nonroot

CMD ["run", "--allow-net", "main.ts"]

and build and run this locally:

$ docker build -t app . && docker run -it --init -p 1993:1993 app

See example directory, however in distroless the explicit vector is required for RUN etc (e.g. see above Dockerfile) since there is no shell.

Note: DENO_DIR is set to /deno-dir/ (which can be overridden). Distroless provides nonroot and nobody users.

Tag summary

Content type

Image

Digest

Size

40 MB

Last updated

over 5 years ago

docker pull hayd/distroless-deno