Coder Social home page Coder Social logo

lucacasonato / deno-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from denoland/deno_docker

1.0 2.0 0.0 12.63 MB

Latest dockerfiles and images for deno - alpine, centos, debian, ubuntu

Home Page: https://hub.docker.com/r/hayd/deno

License: MIT License

Dockerfile 96.41% TypeScript 3.59%

deno-docker's Introduction

Deno Docker

Docker files for deno published on Dockerhub:

ci status

The amazonlinux1 build is used to run deno on AWS Lambda.


Run locally

To start the deno repl:

$ docker run -it --init hayd/alpine-deno:1.2.1 repl

To shell into the docker runtime:

$ docker run -it --init --entrypoint sh hayd/alpine-deno:1.2.1

To run main.ts from your working directory:

$ docker run -it --init -p 1993:1993 -v $PWD:/app hayd/alpine-deno:1.2.1 --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

FROM hayd/alpine-deno:1.2.1

EXPOSE 1993  # The port that your application listens to.

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 main.ts

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

and build and run this locally:

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

(optional) Add deno alias to your shell

Alternatively, you can add deno command to your shell init file (e.g. .bashrc):

deno () {
  docker run \
    --interactive \
    --tty \
    --rm \
    --volume $PWD:/app \
    --volume $HOME/.deno:/deno-dir \
    --workdir /app \
    hayd/alpine-deno:1.2.1 \
    "$@"
}

and in your terminal

$ 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.

deno-docker's People

Contributors

abdelrahman-elkady avatar adekau avatar codepope avatar cqh963852 avatar eternalllight avatar hayd avatar lsagetlethias avatar lucacasonato avatar meteorlxy avatar minigugus avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.