Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denoland/deno_docker
Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
https://github.com/denoland/deno_docker
deno docker dockerfile typescript
Last synced: 7 days ago
JSON representation
Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
- Host: GitHub
- URL: https://github.com/denoland/deno_docker
- Owner: denoland
- License: mit
- Created: 2019-01-06T03:08:16.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T13:09:51.000Z (about 2 months ago)
- Last Synced: 2024-10-29T15:21:47.088Z (about 1 month ago)
- Topics: deno, docker, dockerfile, typescript
- Language: Dockerfile
- Homepage: https://hub.docker.com/r/denoland/deno
- Size: 12.7 MB
- Stars: 916
- Watchers: 19
- Forks: 101
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - deno_docker - alpine, centos, debian, ubuntu | denoland | 555 | (Dockerfile)
- awesome-starred - denoland/deno_docker - Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu (typescript)
- awesome-deno - deno_docker - Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu. (Tools / XML)
README
# deno_docker
Docker files for [Deno](https://github.com/denoland/deno) published on
Dockerhub:- Alpine Linux: [denoland/deno:alpine](https://hub.docker.com/r/denoland/deno)
- Debian: [denoland/deno:debian](https://hub.docker.com/r/denoland/deno)
(default)
- Distroless: [denoland/deno:distroless](https://hub.docker.com/r/denoland/deno)
- Ubuntu: [denoland/deno:ubuntu](https://hub.docker.com/r/denoland/deno)
- Only the binary: [denoland/deno:bin](https://hub.docker.com/r/denoland/deno)![ci status](https://github.com/denoland/deno_docker/workflows/ci/badge.svg?branch=main)
---
## Run locally
To start the `deno` repl:
```sh
$ docker run -it denoland/deno:2.1.2 repl
```To shell into the docker runtime:
```sh
$ docker run -it denoland/deno:2.1.2 sh
```To run `main.ts` from your working directory:
```sh
$ docker run -it -p 1993:1993 -v $PWD:/app denoland/deno:2.1.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
`--allow-net /app/main.ts` is passed to deno on the container.## As a Dockerfile
```Dockerfile
FROM denoland/deno:2.1.2# The port that your application listens to.
EXPOSE 1993WORKDIR /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 install --entrypoint deps.ts# These steps will be re-run upon each file change in your working directory:
COPY . .
# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache main.tsCMD ["run", "--allow-net", "main.ts"]
```and build and run this locally:
```sh
$ docker build -t app . && docker run -it -p 1993:1993 app
```## Using your own base image
If you prefer to install `deno` in your own base image, you can use the
`denoland/deno:bin` to simplify the process.```Dockerfile
FROM ubuntu
COPY --from=denoland/deno:bin-2.1.2 /deno /usr/local/bin/deno
```## Running on Google Cloud Run(GCR)
Due to conflicts with google cloud run caching mechanism it's required to use different path for `DENO_DIR` in your Dockerfile.```Dockerfile
# set DENO_DIR to avoid conflicts with google cloud
ENV DENO_DIR=./.deno_cache
```Without it GCR instance will try to download deps every time. When running with `--cached-only` you will get `Specified not found in cache`.
## (optional) Add `deno` alias to your shell
Alternatively, you can add `deno` command to your shell init file (e.g.
`.bashrc`):```sh
deno () {
docker run \
--interactive \
--tty \
--rm \
--volume $PWD:/app \
--volume $HOME/.deno:/deno-dir \
--workdir /app \
denoland/deno:2.1.2 \
"$@"
}
```and in your terminal
```sh
$ source ~/.bashrc
$ deno --version
$ deno run ./main.ts
```---
See example directory.
Note: Dockerfiles provide a USER `deno` and DENO_DIR is set to `/deno-dir/`
(which can be overridden)._If running multiple Deno instances within the same image you can mount this
directory as a shared volume._## Thanks
Thanks to [Andy Hayden](https://github.com/hayd) for maintaining and setting up
these images.