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 support for Node v12 and v14 #556

Merged
merged 4 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ container_bundle(
"gcr.io/{PROJECT_ID}/python3:debug-nonroot": "//experimental/python3:debug_nonroot",
"gcr.io/{PROJECT_ID}/python2.7:latest": "//experimental/python2.7:python27",
"gcr.io/{PROJECT_ID}/python2.7:debug": "//experimental/python2.7:debug",
"gcr.io/{PROJECT_ID}/nodejs:latest": "//experimental/nodejs",
"gcr.io/{PROJECT_ID}/nodejs:debug": "//experimental/nodejs:debug",
"gcr.io/{PROJECT_ID}/nodejs:latest": "//experimental/nodejs:nodejs10",
"gcr.io/{PROJECT_ID}/nodejs:10": "//experimental/nodejs:nodejs10",
"gcr.io/{PROJECT_ID}/nodejs:12": "//experimental/nodejs:nodejs12",
"gcr.io/{PROJECT_ID}/nodejs:14": "//experimental/nodejs:nodejs14",
"gcr.io/{PROJECT_ID}/nodejs:debug": "//experimental/nodejs:nodejs10_debug",
"gcr.io/{PROJECT_ID}/nodejs:10-debug": "//experimental/nodejs:nodejs10_debug",
"gcr.io/{PROJECT_ID}/nodejs:12-debug": "//experimental/nodejs:nodejs12_debug",
"gcr.io/{PROJECT_ID}/nodejs:14-debug": "//experimental/nodejs:nodejs14_debug",
"gcr.io/{PROJECT_ID}/dotnet:latest": "//experimental/dotnet:dotnet_debian9",
"gcr.io/{PROJECT_ID}/dotnet:debug": "//experimental/dotnet:dotnet_debug_debian9",
"gcr.io/{PROJECT_ID}/dotnet-debian9:latest": "//experimental/dotnet:dotnet_debian9",
Expand Down
29 changes: 24 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,33 @@ http_archive(
urls = ["https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.22.v20191022/jetty-distribution-9.4.22.v20191022.tar.gz"],
)

# Node
# Node (https://nodejs.org/en/about/releases/)
# Follow Node's maintainence schedule and support all LTS versions that are not end of life
http_archive(
name = "nodejs",
name = "nodejs10",
build_file = "//experimental/nodejs:BUILD.nodejs",
sha256 = "417bdc5402f6510fe1a5a898a9cdf1d67bd0202b5f014051c382f05358999534",
strip_prefix = "node-v10.17.0-linux-x64/",
sha256 = "aa7e9e1d8abcc169119bf5c56ede515689f2644ccc4d40ca0fc33756a3deb1f7",
strip_prefix = "node-v10.22.0-linux-x64/",
type = "tar.gz",
urls = ["https://nodejs.org/dist/v10.17.0/node-v10.17.0-linux-x64.tar.gz"],
urls = ["https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.gz"],
)

http_archive(
name = "nodejs12",
build_file = "//experimental/nodejs:BUILD.nodejs",
sha256 = "8cdacecc43c35bcfa5474c793b9e7a01835e4171264f7b13f3e57093371872e9",
strip_prefix = "node-v12.18.3-linux-x64/",
type = "tar.gz",
urls = ["https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.gz"],
)

http_archive(
name = "nodejs14",
build_file = "//experimental/nodejs:BUILD.nodejs",
sha256 = "5e2c59200c86c37a0c800fe2cd2cfabc459f8a3ae3f83c3611483c485ad32e4f",
strip_prefix = "node-v14.6.0-linux-x64/",
type = "tar.gz",
urls = ["https://nodejs.org/dist/v14.6.0/node-v14.6.0-linux-x64.tar.gz"],
)

http_archive(
Expand Down
24 changes: 20 additions & 4 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ steps:
bazel run --host_force_python=PY2 //experimental/python2.7:debug_debian9
bazel run --host_force_python=PY2 //experimental/python2.7:debug_debian10

bazel run --host_force_python=PY2 //experimental/nodejs
bazel run --host_force_python=PY2 //experimental/nodejs:debug
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs10
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs10_debug
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs12
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs12_debug
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs14
bazel run --host_force_python=PY2 //experimental/nodejs:nodejs14_debug

bazel run --host_force_python=PY2 //experimental/dotnet:dotnet_debian9
bazel run --host_force_python=PY2 //experimental/dotnet:dotnet_debian10
Expand Down Expand Up @@ -198,8 +202,14 @@ steps:
docker tag bazel/experimental/python2.7:debug_debian9 gcr.io/$PROJECT_ID/python2.7-debian9:debug
docker tag bazel/experimental/python2.7:debug_debian10 gcr.io/$PROJECT_ID/python2.7-debian10:debug

docker tag bazel/experimental/nodejs:nodejs gcr.io/$PROJECT_ID/nodejs:latest
docker tag bazel/experimental/nodejs:debug gcr.io/$PROJECT_ID/nodejs:debug
docker tag bazel/experimental/nodejs:nodejs10 gcr.io/$PROJECT_ID/nodejs:latest
docker tag bazel/experimental/nodejs:nodejs10 gcr.io/$PROJECT_ID/nodejs:10
docker tag bazel/experimental/nodejs:nodejs12 gcr.io/$PROJECT_ID/nodejs:12
docker tag bazel/experimental/nodejs:nodejs14 gcr.io/$PROJECT_ID/nodejs:14
docker tag bazel/experimental/nodejs:nodejs10_debug gcr.io/$PROJECT_ID/nodejs:debug
docker tag bazel/experimental/nodejs:nodejs10_debug gcr.io/$PROJECT_ID/nodejs:10-debug
docker tag bazel/experimental/nodejs:nodejs12_debug gcr.io/$PROJECT_ID/nodejs:12-debug
docker tag bazel/experimental/nodejs:nodejs14_debug gcr.io/$PROJECT_ID/nodejs:14-debug

docker tag bazel/experimental/dotnet:dotnet_debian9 gcr.io/$PROJECT_ID/dotnet:latest
docker tag bazel/experimental/dotnet:dotnet_debian9 gcr.io/$PROJECT_ID/dotnet-debian9:latest
Expand Down Expand Up @@ -300,7 +310,13 @@ images:
- 'gcr.io/$PROJECT_ID/python2.7-debian10:latest'
- 'gcr.io/$PROJECT_ID/python2.7-debian10:debug'
- 'gcr.io/$PROJECT_ID/nodejs:latest'
- 'gcr.io/$PROJECT_ID/nodejs:10'
- 'gcr.io/$PROJECT_ID/nodejs:12'
- 'gcr.io/$PROJECT_ID/nodejs:14'
- 'gcr.io/$PROJECT_ID/nodejs:debug'
- 'gcr.io/$PROJECT_ID/nodejs:10-debug'
- 'gcr.io/$PROJECT_ID/nodejs:12-debug'
- 'gcr.io/$PROJECT_ID/nodejs:14-debug'
- 'gcr.io/$PROJECT_ID/dotnet:latest'
- 'gcr.io/$PROJECT_ID/dotnet:debug'
- 'gcr.io/$PROJECT_ID/dotnet-debian9:latest'
Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_image")
# https://howtonode.org/hello-node
container_image(
name = "hello",
base = "//experimental/nodejs:nodejs",
base = "//experimental/nodejs:nodejs10",
cmd = ["hello.js"],
files = [":hello.js"],
)

container_image(
name = "hello_http",
base = "//experimental/nodejs:nodejs",
base = "//experimental/nodejs:nodejs10",
cmd = ["hello_http.js"],
files = [":hello_http.js"],
ports = ["8000"],
Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:10.17.0 AS build-env
FROM node:10 AS build-env
ADD . /app
WORKDIR /app

RUN npm ci --only=production

FROM gcr.io/distroless/nodejs
FROM gcr.io/distroless/nodejs:10
COPY --from=build-env /app /app
WORKDIR /app
CMD ["hello.js"]
4 changes: 2 additions & 2 deletions examples/nodejs/node-express/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:10.17.0 AS build-env
FROM node:10 AS build-env
ADD . /app
WORKDIR /app
RUN npm install --production

FROM gcr.io/distroless/nodejs
FROM gcr.io/distroless/nodejs:10
COPY --from=build-env /app /app
WORKDIR /app
EXPOSE 3000
Expand Down
24 changes: 15 additions & 9 deletions experimental/nodejs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_docker//container:container.bzl", "container_image")

[container_image(
name = "nodejs" if (not mode) else mode[1:],
base = "//cc" + mode,
entrypoint = ["/nodejs/bin/node"],
tars = ["@nodejs//:tar"],
) for mode in [
"",
":debug",
]]
NODEJS_MAJOR_VERISONS = ("10", "12", "14")

[
container_image(
name = "nodejs" + major_version + ("" if (not mode) else mode),
base = ("//cc:cc" if (not ("debug" in mode)) else "//cc:debug"),
entrypoint = ["/nodejs/bin/node"],
tars = ["@nodejs" + major_version + "//:tar"],
)
for mode in [
"",
"_debug",
]
for major_version in NODEJS_MAJOR_VERISONS
]
10 changes: 7 additions & 3 deletions experimental/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## Image Contents

This image contains a minimal Linux, Node.js-based runtime.
These images contain a minimal Linux, Node.js-based runtime. The supported versions match the [Node.js LTS releases](https://nodejs.org/en/about/releases/).

Specifically, the image contains everything in the [base image](../../base/README.md), plus:
Specifically, these images contain everything in the [base image](../../base/README.md), plus one of:

- Node.js v10.16.3 and its dependencies.
- Node.js v10 (`gcr.io/distroless/nodejs:10`) and its dependencies.
- Node.js v12 (`gcr.io/distroless/nodejs:12`) and its dependencies.
- Node.js v14 (`gcr.io/distroless/nodejs:14`) and its dependencies.

michael-gillett marked this conversation as resolved.
Show resolved Hide resolved
**Note:** the `latest` tag maps to Node.js v10 for backwards compatibility and is now deprecated. Once Node.js v10 reaches EOL on 2021-04-30, the `latest` tag will be removed to avoid confusion. Users of these images should explicitly set the LTS version tag they wish to use.

## Usage

Expand Down