FROM debian:bullseye-slim AS builder

ENV DENO_VERSION=1.2.1

WORKDIR /build

RUN apt-get update && apt-get install -y curl zip

RUN curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip --output deno.zip
RUN unzip deno.zip
RUN rm deno.zip
RUN chmod 777 deno
RUN chmod +x deno
RUN mv deno /usr/bin/deno

FROM debian:bullseye-slim

COPY --from=builder /usr/bin/deno /usr/bin/deno

RUN ls /usr/bin/deno

WORKDIR /app

COPY src/deps.ts /app/src/deps.ts

RUN /usr/bin/deno cache --unstable src/deps.ts

ADD src /app/src

RUN /usr/bin/deno cache --unstable src/registry.ts

VOLUME [ "/app/data" ]
ENTRYPOINT [ "/usr/bin/deno", "run", "-A", "--unstable", "/app/src/registry.ts" ]