无法创建 deno docker 图像

Cannot create deno docker image

我想使用 Dockerfile

创建 deno docker 镜像
FROM alpine:latest

WORKDIR /

RUN apk update && \
    apk upgrade

RUN apk add curl

RUN curl -fsSL https://deno.land/x/install/install.sh | sh

ENV DENO_INSTALL="/root/.deno"

ENV PATH="${DENO_INSTALL}/bin:${PATH}"

RUN deno --help

但是当运行docker build -t deno .最后显示/bin/sh: deno: not found

完整输出:

Sending build context to Docker daemon  54.78kB
Step 1/8 : FROM alpine:latest
 ---> f70734b6a266
Step 2/8 : WORKDIR /
 ---> Using cache
 ---> b1bbfa810906
Step 3/8 : RUN apk update &&     apk upgrade
 ---> Using cache
 ---> a7761425faba
Step 4/8 : RUN apk add curl
 ---> Using cache
 ---> 9099d4f65cb1
Step 5/8 : RUN curl -fsSL https://deno.land/x/install/install.sh | sh
 ---> Using cache
 ---> b4ea95c69a73
Step 6/8 : ENV DENO_INSTALL="/root/.deno"
 ---> Using cache
 ---> bdc7e1e85e9c
Step 7/8 : ENV PATH="${DENO_INSTALL}/bin:${PATH}"
 ---> Using cache
 ---> d35db1caba71
Step 8/8 : RUN deno --help
 ---> Running in d1ca4e1d0dc6
/bin/sh: deno: not found
The command '/bin/sh -c deno --help' returned a non-zero code: 127

Alpine 缺少 glibc,这是 deno 到 运行 所需要的。

您可以使用 frolvlad/alpine-glibc:alpine-3.11_glibc-2.31 代替,它会正常工作。

FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31

WORKDIR /

RUN apk update && \
    apk upgrade

RUN apk add curl

RUN curl -fsSL https://deno.land/x/install/install.sh | sh

ENV DENO_INSTALL="/root/.deno"

ENV PATH="${DENO_INSTALL}/bin:${PATH}"

RUN deno --help

我建议构建一个特定的 deno 版本,为此,您应该使用:

curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31

ENV DENO_VERSION=1.0.0

# ...

RUN curl -fsSL https://deno.land/x/install/install.sh | sh -s v${DENO_VERSION}

# ...

您还可以查看 deno-docker