Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-stage docker image for alpine without glibc #5

Open
hayd opened this issue Oct 27, 2019 · 6 comments
Open

Add multi-stage docker image for alpine without glibc #5

hayd opened this issue Oct 27, 2019 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@hayd
Copy link
Contributor

hayd commented Oct 27, 2019

You have to first build gn using ubuntu then build deno with gn in alpine.
This should be possible, and I have some progress towards it... (failing) attempt: Dockerfile.
failure output

This may also be useful for automating creating of binaries suitable for AWS Lambda (or similar). The tricky part is to not rely on glibc... This is complete.

Note/Aside: Current size is 62Mb (18.1Mb compressed).

See also denoland/deno#1456 and https://dev.to/kt3k/write-aws-lambda-function-in-deno-4b20.

xpost: denoland/deno#3243

@hayd hayd added the help wanted Extra attention is needed label Aug 11, 2020
@webdeb
Copy link

webdeb commented Nov 10, 2020

Not exactly sure how this is related, but I am running a multi-stage build by running deno bundle app.ts app.bundle.js in the first stage and then copying the produced file into the final image. Works nice! This is a just a simple events handler and the size of the app.bundle.js is about 450kb.

@hayd
Copy link
Contributor Author

hayd commented Nov 11, 2020

@webdeb An example like that would be really nice for the README, I think that's a better option that running bundle locally (on potentially another deno version) then using that file 👍

@webdeb
Copy link

webdeb commented Nov 11, 2020

@hayd sure!

Please feel free to include it, I just copied what I have locally in my project (just updated it according to the new release):

FROM hayd/alpine-deno:1.5.2 as build
ADD . .
RUN deno bundle --importmap=./import_map.json --unstable ./app.ts /tmp/app.bundle.js

# --- build the final image, include only the app.bundle.js
FROM hayd/alpine-deno:1.5.2
WORKDIR /app
USER deno
ENV MODE=production

COPY --from=build /tmp/app.bundle.js /app/app.bundle.js
CMD ["deno", "run", "--allow-net", "--allow-env", "--allow-read", "/app/app.bundle.js"]

@CanRau
Copy link

CanRau commented Oct 21, 2021

@webdeb Why use bundle and not compile?

Trying to "improve" my Dockerfile though both of those produce the same error, which I not get running the server using deno run

The bundle'd at least show a more insightful error & lets me inspect

error: Uncaught ReferenceError: Cannot access 'Error' before initialization
class DenoStdInternalError extends Error {

Thoug I've no idea what to do, probably opening a new issue @ denoland/deno right?

@webdeb
Copy link

webdeb commented Oct 21, 2021

@CanRau Oh your are right. I guess by that time the compile command wasn't available.
Your error seems weird and reporting it is a good idea, however to fix workaround your problem maybe you could try to define a Variable like const ExtendableError = Error
and then use it like MyError extend ExtendableError {}
Don't know if this will work, but it could ;)

@CanRau
Copy link

CanRau commented Oct 21, 2021

Huh, just found denoland/deno#12086 and it's "duplicate" denoland/deno#12477

@webdeb I'm not directly using Error in my code, at least as far as I recall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants