Skip to content
Closed
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
5 changes: 3 additions & 2 deletions kubernetes/docker/edgemicro/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM node:24.18.0-trixie-slim
FROM node:24.18.1-trixie-slim

# === SECURITY PATCH LAYER ===
# 1. Update OS packages to resolve Debian CVEs
# 2. Force-update global npm to resolve NPM CVEs
RUN apt-get update && \
apt-get upgrade -y && \
npm install -g npm@latest && \
npm config set allow-git all --global && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ============================
Expand All @@ -18,7 +19,7 @@ COPY --chown=101:101 installedgemicro.sh /tmp
RUN addgroup --system --gid 101 apigee && \
adduser --shell /bin/bash --uid 101 --system --ingroup apigee --home /opt/apigee apigee

ENV NODE_ENV production
ENV NODE_ENV=production

#install node.js
RUN chmod +x /tmp/installnode.sh && \
Expand Down
5 changes: 3 additions & 2 deletions kubernetes/docker/edgemicro/Dockerfile.beta
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM node:24.18.0-trixie-slim
FROM node:24.18.1-trixie-slim

# === SECURITY PATCH LAYER ===
# 1. Update OS packages to resolve Debian CVEs
# 2. Force-update global npm to resolve NPM CVEs
RUN apt-get update && \
apt-get upgrade -y && \
npm install -g npm@latest && \
npm config set allow-git all --global && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ============================
Expand All @@ -18,7 +19,7 @@ COPY --chown=101:101 installedgemicro.sh /tmp
RUN addgroup --system --gid 101 apigee && \
adduser --shell /bin/bash --uid 101 --system --ingroup apigee --home /opt/apigee apigee

ENV NODE_ENV production
ENV NODE_ENV=production

#install node.js
RUN chmod +x /tmp/installnode.sh && \
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/docker/edgemicro/betabuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fi
if [ "$branch" == "npm" ]; then
sed -i.bak "s|npm install.*-g edgemicro.*|npm install --omit=dev --omit=optional -g edgemicro@$semver|g" installnode.sh
else
sed -i.bak "s|npm install.*-g edgemicro.*|npm install --omit=dev --omit=optional -g ${repo}#$branch|g" installnode.sh
sed -i.bak "s|npm install.*-g edgemicro.*|npm install --omit=dev --omit=optional --allow-git=all -g ${repo}#$branch|g" installnode.sh
fi

# Clear older image and build cache
Expand Down
70 changes: 56 additions & 14 deletions kubernetes/docker/edgemicro/dockerbuild.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,69 @@
#!/bin/bash

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ $# -ne 2 ]; then
echo "Please provide edgemicro version and GCP project id"
exit 1
if [ $# -lt 1 ]; then
echo "Usage: $0 <edgemicro-version> [gcp-project-id] [--dry-run]"
echo "Example: $0 3.3.11"
echo "Example: $0 3.3.11 --dry-run"
exit 1
fi

version=$1
project_id=$2
project_id="apigee-microgateway"
dry_run=false

for arg in "$@"; do
[ "$arg" == "--dry-run" ] && dry_run=true
[[ "$arg" != "--dry-run" && "$arg" != "$version" ]] && project_id="$arg"
done

echo "Checking existing tags in Artifact Registry for $version..."
all_tags=$(gcloud artifacts docker tags list "us-docker.pkg.dev/$project_id/gcr.io/edgemicro" --format="value(tag)" 2>/dev/null || true)

if [ $# -eq 2 ]; then
has_base=false
max=0
for tag in $all_tags; do
[ "$tag" == "$version" ] && has_base=true
if [[ "$tag" =~ ^${version}-sec\.([0-9]+)$ ]]; then
(( BASH_REMATCH[1] > max )) && max="${BASH_REMATCH[1]}"
fi
done

if [ "$has_base" = false ]; then
image_tag="$version"
echo "Base tag '$version' not found. Publishing initial release: $image_tag"
else
image_tag="$version-sec.$((max + 1))"
echo "Base tag '$version' exists. Auto-publishing security rebuild: $image_tag"
fi

sed -i.bak "s|npm install.*-g edgemicro.*|npm install --omit=dev --omit=optional -g edgemicro@$version|g" installnode.sh
docker build --no-cache -t edgemicro:$version $DIR
docker tag edgemicro:$version gcr.io/$project_id/edgemicro:$version
docker tag edgemicro:$version gcr.io/$project_id/edgemicro:latest
docker push gcr.io/$project_id/edgemicro:$version
docker push gcr.io/$project_id/edgemicro:latest
rm installnode.sh
mv installnode.sh.bak installnode.sh
tags_to_push=("$image_tag" "latest")
echo "NPM package: edgemicro@$version"
echo "Image tags: ${tags_to_push[*]}"

if [ "$dry_run" = true ]; then
echo "[DRY RUN] Finished check. No images built or pushed."
exit 0
fi

# Configure Docker for gcr.io if not already configured
if [ ! -f ~/.docker/config.json ] || ! grep -q "gcr.io" ~/.docker/config.json; then
echo "Configuring Docker for gcr.io..."
gcloud auth configure-docker gcr.io --quiet
fi

# Always restore installnode.sh on exit
trap 'mv -f installnode.sh.bak installnode.sh 2>/dev/null || true' EXIT
sed -i.bak "s|npm install.*-g edgemicro.*|npm install --omit=dev --omit=optional -g edgemicro@$version|g" installnode.sh

docker build --provenance=false --pull --no-cache -t edgemicro:$image_tag "$DIR"

for t in "${tags_to_push[@]}"; do
echo "Pushing: gcr.io/$project_id/edgemicro:$t"
docker tag edgemicro:$image_tag "gcr.io/$project_id/edgemicro:$t"
docker push "gcr.io/$project_id/edgemicro:$t"
done

echo "Successfully published: ${tags_to_push[*]}"
3 changes: 3 additions & 0 deletions kubernetes/docker/edgemicro/installnode.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -e

# Allow installing dependencies directly from Git repositories (npm v12+)
npm config set allow-git all --global || true

# 1. Install globally (this line is targeted by betabuild.sh's sed replacement)
npm install --omit=dev --omit=optional -g edgemicro

Expand Down
Loading