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

Fixup #2

Draft
wants to merge 1 commit into
base: od-dockerize-nextjs
Choose a base branch
from

Conversation

gregmagolan
Copy link

@gregmagolan gregmagolan commented May 4, 2024

On MacOS, bzlmod node toolchains have a bug for transitions so to build the image with the correct node toolchain you need add --extra_toolchains:

bazel run //next.js:image_tarball --extra_toolchains=@nodejs_toolchains//:linux_arm64_toolchain_target

That followed by

docker run -it -p 3000:3000 examples_nextjs:latest

should start the webserver

"node",
dev_dependency = True,
)
use_repo(node, "nodejs_toolchains")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed on MacOS under bzlmod to run

--extra_toolchains=@nodejs_toolchains//:linux_arm64_toolchain_target

WORKSPACE does not have this issue on transitions

],
)

next_bin.next_binary(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a js_run_devserver binary which is for local development and won't work in a container, what you want for the image is just a js_binary which is what next_bin.next_binary is under the hood

name = "image",
base = "@debian_node",
cmd = ["/app/next.js/next_js_start"],
workdir = "/app/next.js/next_js_start.runfiles/_main",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workdir must be set to the root of the runfiles tree in the container

js_image_layer(
name = "layers",
binary = ":next_js_start",
platform = select({
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For transitioning the target platform to linux for for the container runtime so the image can be built locally on a mac

@be9 be9 changed the base branch from main to od-dockerize-nextjs May 6, 2024 06:07
@gregmagolan
Copy link
Author

Related to aspect-build/rules_js#1530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant