From 3efe3d3cf0fdf1b65f8e6845ee37d193bbc76ac8 Mon Sep 17 00:00:00 2001 From: Kalaiselvim <117940852+Kalaiselvi84@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:20:33 +0000 Subject: [PATCH] Update Nodejs Apt Repository to latest (#3435) --- examples/nodejs-simple/Dockerfile | 21 +++++++++------------ examples/nodejs-simple/Makefile | 4 ++-- examples/nodejs-simple/README.md | 12 ++++++------ examples/nodejs-simple/gameserver.yaml | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/examples/nodejs-simple/Dockerfile b/examples/nodejs-simple/Dockerfile index d5ee01014d..15edaac202 100644 --- a/examples/nodejs-simple/Dockerfile +++ b/examples/nodejs-simple/Dockerfile @@ -17,20 +17,17 @@ RUN useradd -u 1000 -m server RUN apt-get update && apt-get install -y curl software-properties-common gnupg && \ apt-get clean -RUN add-apt-repository -y -r ppa:chris-lea/node.js -RUN rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list -RUN rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save +# Import the Nodesource GPG key +RUN apt-get update && \ + apt-get install -y ca-certificates curl gnupg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg -ARG KEYRING=/usr/share/keyrings/nodesource.gpg -ARG VERSION=node_18.x - -RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee "$KEYRING" >/dev/null -RUN gpg --no-default-keyring --keyring "$KEYRING" --list-keys - -ARG DISTRO="bullseye" -RUN echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list -RUN echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list +# Create deb repository for a specific Node major version +ARG NODE_MAJOR=20 +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list +# Update and install Node.js RUN apt-get update && apt-get install -y nodejs WORKDIR /home/server diff --git a/examples/nodejs-simple/Makefile b/examples/nodejs-simple/Makefile index 3426ec32d1..0efc2ac2b0 100644 --- a/examples/nodejs-simple/Makefile +++ b/examples/nodejs-simple/Makefile @@ -31,9 +31,9 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) project_path := $(dir $(mkfile_path)) root_path = $(realpath $(project_path)/../..) ifeq ($(REPOSITORY),) - server_tag := nodejs-simple-server:0.8 + server_tag := nodejs-simple-server:0.9 else - server_tag := $(REPOSITORY)/nodejs-simple-server:0.8 + server_tag := $(REPOSITORY)/nodejs-simple-server:0.9 endif # _____ _ diff --git a/examples/nodejs-simple/README.md b/examples/nodejs-simple/README.md index 93e17be4bf..801c8f26a5 100644 --- a/examples/nodejs-simple/README.md +++ b/examples/nodejs-simple/README.md @@ -42,7 +42,7 @@ $ make run The example can also be run via docker: ``` -$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 +$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 ``` Or directly via npm: ``` @@ -51,7 +51,7 @@ $ npm start You will see the output like the following: ``` -docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 +docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 > @ start /home/server/examples/nodejs-simple > node src/index.js @@ -63,7 +63,7 @@ Connecting to the SDK server... To see help, pass `--help` as the argument (use the preferred command below, all are equivalent): ``` $ make args="--help" run -$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 --help +$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 --help $ npm start -- --help ``` @@ -71,14 +71,14 @@ You can optionally specify how long the server will stay up once the basic tests To do this pass arguments through, e.g. to increase the shutdown duration to 120 seconds: ``` $ make args="--timeout=120" run -$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 --timeout=120 +$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 --timeout=120 $ npm start -- --timeout=120 ``` To make run indefinitely use the special timeout value of 0: ``` $ make args="--timeout=0" run -$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 --timeout=0 +$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 --timeout=0 $ npm start -- --timeout=0 ``` @@ -90,6 +90,6 @@ $ cd ../../build; make run-sdk-conformance-local TIMEOUT=120 FEATURE_GATES="Play Then enable the alpha suite: ``` $ make args="--alpha" run -$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 --alpha +$ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 --alpha $ npm start -- --alpha ``` diff --git a/examples/nodejs-simple/gameserver.yaml b/examples/nodejs-simple/gameserver.yaml index fd6d915fda..361c386a4c 100644 --- a/examples/nodejs-simple/gameserver.yaml +++ b/examples/nodejs-simple/gameserver.yaml @@ -32,5 +32,5 @@ spec: spec: containers: - name: nodejs-simple - image: us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.8 + image: us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9 # args: ["--timeout=0"] # Change the timeout here, if you like the nodejs server to run longer.