-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile-deno.Dockerfile
65 lines (42 loc) · 1.75 KB
/
Dockerfile-deno.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# https://github.com/denoland/deno_docker/blob/main/example/Dockerfile
FROM denoland/deno:alpine-2.0.0 AS base
WORKDIR /app
RUN apk add --no-cache libstdc++ dumb-init git
COPY package.json pnpm-lock.yaml ./
RUN deno install
FROM base AS builder
COPY src src/
COPY index.ts esbuild.ts ./
RUN deno --allow-env --allow-read --allow-run esbuild.ts
FROM base AS dev
ENV DENO_DIR=/app/.deno_cache
# manually mount src etc
CMD ["deno", "--allow-env", "--allow-read", "--allow-run", "--allow-net", "--allow-sys", "--unstable-sloppy-imports", "index.ts"]
# https://github.com/evanw/esbuild/issues/1921
FROM denoland/deno:alpine-2.0.0 AS prod
WORKDIR /app
RUN apk add --no-cache libstdc++ dumb-init git
# TODO maybe in future. Results in breaking change
#USER node
COPY --from=builder /app/bundle.cjs /app/index.cjs
ENV DENO_DIR=/app/.deno_cache
# Compile cache / modify for multi-user
RUN deno cache --unstable-sloppy-imports index.cjs || true
RUN chmod uga+rw -R ${DENO_DIR}
# Not sure about those options
#--cached-only
#--no-code-cache
# TODO not sure about this
# Run with dumb-init to not start node with PID=1, since Node.js was not designed to run as PID 1
CMD ["dumb-init", "deno", "--allow-env", "--allow-read", "--allow-run", "--allow-net", "--allow-sys", "--unstable-sloppy-imports", "index.cjs"]
# BUN Sample
# FROM oven/bun:1.1.30-alpine AS prod
# WORKDIR /app
# RUN apk add --no-cache libstdc++ dumb-init git
# # TODO maybe in future. Results in breaking change
# #USER node
# COPY --from=builder /app/bundle.cjs /app/index.cjs
# ENV CONFIG_LOCATION=/app/config/config.yml
# ENV SECRETS_LOCATION=/app/config/secrets.yml
# # Run with dumb-init to not start node with PID=1, since Node.js was not designed to run as PID 1
# CMD ["dumb-init", "bun", "index.cjs"]