-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I'm trying to get the following setup to work:
- SvelteKit
- Deno
- Docker
- fly.io
So basically, I'm not deploying via Deno Deploy but fly.io instead.
Fly.io needs a "working" Docker image to deploy. I can't quite get it to work on the platform, but in fact I can't quite get it to work "locally" (on my own Docker Desktop instance) either.
What does work so far:
- I have a template originally created with
deno run -A npm:sv create my-app(as per https://docs.deno.com/examples/svelte_tutorial/#create-a-sveltekit-app-with-deno) - I therefore have a
package.jsonfile but I'm trying to avoid usingnpmdirectly, so I add dependencies using commands likedeno add -D npm:sass-embeddedwhich updates package.json and deno.lock - I have installed
svelte-adapter-denoand I have modifiedsvelte.config.jsto explicitly use this adapter, i.e.import adapter from 'svelte-adapter-deno'; - I can run
deno task devto serve the dev version (using vite) - I can build the "production" server using
deno task buildwithout any errors - I can serve the compiled/built application using
deno run --allow-env --allow-read --allow-net build/index.js- again, no errors
Now for the Docker part. I have the following Dockerfile, adapted from another Deno fly.io project:
# Based on https://github.com/denoland/deno_docker/blob/main/alpine.dockerfile
ARG DENO_VERSION=1.14.0
ARG BIN_IMAGE=denoland/deno:bin-${DENO_VERSION}
FROM ${BIN_IMAGE} AS bin
FROM frolvlad/alpine-glibc:alpine-3.13
RUN apk --no-cache add ca-certificates
RUN addgroup --gid 1000 deno \
&& adduser --uid 1000 --disabled-password deno --ingroup deno \
&& mkdir /deno-dir/ \
&& chown deno:deno /deno-dir/
ENV DENO_DIR /deno-dir/
ENV DENO_INSTALL_ROOT /usr/local
ARG DENO_VERSION
ENV DENO_VERSION=${DENO_VERSION}
COPY --from=bin /deno /bin/deno
WORKDIR /deno-dir
COPY . .
ENTRYPOINT ["/bin/deno"]
CMD ["run", "--allow-env", "--allow-read", "--allow-net", "build/index.js"]
I can then successfully build the Docker image:
docker build . --tag sv-deno- no errors
What does not work:
docker run sv-deno
The container launches but soon I get a ton of errors such as:
Check file:///deno-dir/build/index.js
error: TS1005 [ERROR]: ',' expected.
type ErrorStatus,
~~~~~~~~~~~
at https://deno.land/std@0.152.0/http/http_errors.ts:49:8
v11.1.0/mod.ts:93:15
and
TS2531 [ERROR]: Object is possibly 'null'.
actualTypeStr = actual.constructor?.name ?? "Object";
~~~~~~
at https://deno.land/std@0.152.0/testing/asserts.ts:359:23
and
TS2300 [ERROR]: Duplicate identifier 'type'.
type TokensToRegexpOptions,
~~~~
at https://deno.land/x/oak@v11.1.0/deps.ts:63:3
TS2305 [ERROR]: Module '"https://deno.land/std@0.152.0/async/deferred.ts"' has no exported member 'type'.
type Deferred,
~~~~
at https://deno.land/x/oak@v11.1.0/deps.ts:8:3
...and so on.
These are the errors I see when trying to run the container locally. They are the same errors I see when trying to deploy the app on fly.io as well, which I suppose is to be expected.
Any ideas for how to set up the Dockerfile and/or the adapter and/or Deno itself in order to run my SvelteKit app successfully from Deno+Docker?