1. Reference
https://zenn.dev/shinkano/articles/280518001ad0d6
2. Create directory
$ mkdir Deno $ cd Deno
3. Create Dockerfile
$ vi Dockerfile $ cat Dockerfile FROM debian:stable-slim WORKDIR /var/www/html RUN apt-get -qq update \ && apt-get -qq -y install curl zip unzip \ && curl -fsSL https://deno.land/x/install/install.sh | sh \ && apt-get -qq remove curl zip unzip \ && apt-get -qq remove --purge -y curl zip unzip \ && apt-get -qq -y autoremove \ && apt-get -qq clean \ && echo 'export DENO_INSTALL="/root/.deno"' >> ~/.bash_profile \ && echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.bash_profile CMD ["/bin/bash", "-c", "source ~/.bash_profile && bash"]
4. Build image
$ docker build ./ -t deno-docker
5. Run docker container
$ docker container run -it \ --rm \ -p 8080:8080 \ --mount src=`pwd`,target=/var/www/html,type=bind \ --disable-content-trust \ deno-docker root@85d751a4ee15:/var/www/html#
6. Install vim in docker
# apt-get update # apt-get install vim
7. Create main.ts
– Can not copy & paste from clipbord to vim file
– So i have to manually enter
# vi main.ts # cat main.ts import { serve } from "https://deno.land/std@0.50.0/http/server.ts"; const s = serve({ port: 8080 }); // コンテナに指定したポート console.log("http://localhost:8080/"); for await (const req of s) { req.respond({ body: "<h1>Hello Deno</h1>\n" }); }
8. Execute deno
# deno run --allow-net main.ts
9. Check in browser
10. Check docker ps
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 85d751a4ee15 deno-docker "/bin/bash -c 'sourc…" 54 minutes ago Up 54 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp inspiring_hodgkin
11. Check directory and file
~/Deno$ ls -lai total 20 10365241 drwxrwxr-x 2 wsd01 wsd01 4096 Oct 29 09:48 . 10223618 drwxr-x--- 40 wsd01 wsd01 4096 Oct 29 08:07 .. 10365226 -rw-rw-r-- 1 wsd01 wsd01 697 Oct 29 08:16 docker-compose.yml 10365247 -rw-rw-r-- 1 wsd01 wsd01 526 Oct 29 08:44 Dockerfile 10365085 -rw-r--r-- 1 root root 222 Oct 29 09:48 main.ts
/var/www/html# ls -lai total 20 10365241 drwxrwxr-x 2 1000 1000 4096 Oct 29 00:48 . 4064812 drwxr-xr-x 3 root root 4096 Oct 28 23:44 .. 10365247 -rw-rw-r-- 1 1000 1000 526 Oct 28 23:44 Dockerfile 10365226 -rw-rw-r-- 1 1000 1000 697 Oct 28 23:16 docker-compose.yml 10365085 -rw-r--r-- 1 root root 222 Oct 29 00:48 main.ts
12. Set timezone
(1) tzselect
– select japan
/var/www/html# tzselect
(2) tzconfig
– select tokyo
/var/www/html# tzconfig /var/www/html# date Sat Oct 29 10:04:07 JST 2022 /var/www/html# ls -l total 12 -rw-rw-r-- 1 1000 1000 526 Oct 29 08:44 Dockerfile -rw-rw-r-- 1 1000 1000 697 Oct 29 08:16 docker-compose.yml -rw-r--r-- 1 root root 222 Oct 29 09:48 main.ts