diff --git a/Dockerfile-deno.Dockerfile b/Dockerfile-deno.Dockerfile new file mode 100644 index 0000000..2822951 --- /dev/null +++ b/Dockerfile-deno.Dockerfile @@ -0,0 +1,69 @@ +# 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 CONFIG_LOCATION=/app/config/config.yml +ENV SECRETS_LOCATION=/app/config/secrets.yml +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 CONFIG_LOCATION=/app/config/config.yml +ENV SECRETS_LOCATION=/app/config/secrets.yml +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"] diff --git a/generate-api.js b/generate-api.js index e66f023..91f2b92 100644 --- a/generate-api.js +++ b/generate-api.js @@ -1,5 +1,5 @@ -import { unlinkSync } from "fs"; -import path from "path"; +import { unlinkSync } from "node:fs"; +import path from "node:path"; import { generateApi } from "swagger-typescript-api"; const PATH_TO_OUTPUT_DIR = path.resolve(process.cwd(), "./src/__generated__");