From 3b234ed7155a4fd4260c7edff39bc397d8fd24a9 Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 11:54:16 +0000 Subject: [PATCH 1/6] Fix release download --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index bfc90127..873e4e07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,20 +24,21 @@ COPY . /app # Build the webapp FROM node:23-slim AS webbuilder +# Set the release URL (this should be static and not change often) +ARG LATEST_RELEASE=https://api.github.com/repos/stacklok/codegate-ui/releases/latest + # Install curl for downloading the webapp from GH and unzip to extract it RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ + jq \ unzip\ ca-certificates WORKDIR /usr/src/ -# To ensure we always download the latest release of the webapp, we use a build argument. -# This prevents the curl command from being cached by Docker. - -ARG LATEST_RELEASE=LATEST -RUN echo "Latest FE release: $LATEST_RELEASE" -RUN LATEST_RELEASE=${LATEST_RELEASE} curl -L -o main.zip ${LATEST_RELEASE} +# Download the latest release of the webapp +RUN echo "Latest FE release: $(curl -s ${LATEST_RELEASE} | jq -r '.tag_name')" +RUN curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip # Extract the downloaded zip file RUN unzip main.zip @@ -111,4 +112,4 @@ USER codegate # Set the container's default entrypoint EXPOSE 8989 -ENTRYPOINT ["/app/scripts/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/app/scripts/entrypoint.sh"] From eec0e57d83c50cdea12345735c8521fa9b09f8d7 Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 12:06:51 +0000 Subject: [PATCH 2/6] Fix release download --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 873e4e07..975ca4fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,14 +31,15 @@ ARG LATEST_RELEASE=https://api.github.com/repos/stacklok/codegate-ui/releases/la RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ jq \ - unzip\ + unzip \ ca-certificates WORKDIR /usr/src/ -# Download the latest release of the webapp -RUN echo "Latest FE release: $(curl -s ${LATEST_RELEASE} | jq -r '.tag_name')" -RUN curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip +# Download the latest release of the webapp in one single RUN instruction +RUN TAG=$(curl -s ${LATEST_RELEASE} | jq -r '.tag_name') && \ + echo "Latest FE release: ${TAG}" && \ + curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip # Extract the downloaded zip file RUN unzip main.zip From 3ad4566c4d5ac9326d94592dd6e3b8a5cf12ae2d Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 12:11:02 +0000 Subject: [PATCH 3/6] Fix release download --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 975ca4fb..c5a74ca5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,9 +24,6 @@ COPY . /app # Build the webapp FROM node:23-slim AS webbuilder -# Set the release URL (this should be static and not change often) -ARG LATEST_RELEASE=https://api.github.com/repos/stacklok/codegate-ui/releases/latest - # Install curl for downloading the webapp from GH and unzip to extract it RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ @@ -36,10 +33,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /usr/src/ -# Download the latest release of the webapp in one single RUN instruction -RUN TAG=$(curl -s ${LATEST_RELEASE} | jq -r '.tag_name') && \ - echo "Latest FE release: ${TAG}" && \ - curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip +# Ensure the LATEST_RELEASE argument is passed or set a default value +ARG LATEST_RELEASE="https://api.github.com/repos/stacklok/codegate-ui/releases/latest" +RUN echo "Latest FE release: $LATEST_RELEASE" \ + && TAG=$(curl -s $LATEST_RELEASE | jq -r '.tag_name') \ + && echo "Latest FE release: ${TAG}" \ + && ZIP_URL=$(curl -s $LATEST_RELEASE | jq -r '.zipball_url') \ + && curl -L -o main.zip $ZIP_URL # Extract the downloaded zip file RUN unzip main.zip From b1eeed970e0703399f278cd36363c79287684ddd Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 12:13:35 +0000 Subject: [PATCH 4/6] Fix release download --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5a74ca5..41f8cc87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,22 +24,20 @@ COPY . /app # Build the webapp FROM node:23-slim AS webbuilder + + # Install curl for downloading the webapp from GH and unzip to extract it RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ jq \ - unzip \ + unzip\ ca-certificates WORKDIR /usr/src/ -# Ensure the LATEST_RELEASE argument is passed or set a default value +# Set the release URL (this should be static and not change often) and download latest ARG LATEST_RELEASE="https://api.github.com/repos/stacklok/codegate-ui/releases/latest" -RUN echo "Latest FE release: $LATEST_RELEASE" \ - && TAG=$(curl -s $LATEST_RELEASE | jq -r '.tag_name') \ - && echo "Latest FE release: ${TAG}" \ - && ZIP_URL=$(curl -s $LATEST_RELEASE | jq -r '.zipball_url') \ - && curl -L -o main.zip $ZIP_URL +RUN curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip # Extract the downloaded zip file RUN unzip main.zip From 96698c78e19be950aff29d94c6ec1c107fba990e Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 12:18:58 +0000 Subject: [PATCH 5/6] Fix release download --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 41f8cc87..e2a23b99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,8 +36,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /usr/src/ # Set the release URL (this should be static and not change often) and download latest -ARG LATEST_RELEASE="https://api.github.com/repos/stacklok/codegate-ui/releases/latest" -RUN curl -s ${LATEST_RELEASE} | jq -r '.zipball_url' | xargs curl -L -o main.zip +RUN curl -s https://api.github.com/repos/stacklok/codegate-ui/releases/latest | jq -r '.zipball_url' | xargs curl -L -o main.zip # Extract the downloaded zip file RUN unzip main.zip From cb433e2fbb1949a1bf83279ca5e9213594e7dd95 Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 7 Jan 2025 12:29:43 +0000 Subject: [PATCH 6/6] Fix release download --- .github/workflows/image-build.yml | 6 +++--- Dockerfile | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/image-build.yml b/.github/workflows/image-build.yml index 374f7b23..be35f451 100644 --- a/.github/workflows/image-build.yml +++ b/.github/workflows/image-build.yml @@ -20,10 +20,10 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3 - - name: Fetch latest FE commit SHA - id: fetch_commit_fe_sha + - name: Fetch latest release URL + id: fetch_release_url run: | - echo "LATEST_RELEASE=$(curl -s "https://api.github.com/repos/stacklok/codegate-ui/releases/latest" | grep '"zipball_url":' | cut -d '"' -f 4)" >> $GITHUB_ENV + echo "LATEST_RELEASE=$(curl -s "https://api.github.com/repos/stacklok/codegate-ui/releases/latest" | jq -r '.zipball_url')" >> $GITHUB_ENV - name: Test build on x86 id: docker_build uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v5 diff --git a/Dockerfile b/Dockerfile index e2a23b99..7f1eafee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /usr/src/ -# Set the release URL (this should be static and not change often) and download latest -RUN curl -s https://api.github.com/repos/stacklok/codegate-ui/releases/latest | jq -r '.zipball_url' | xargs curl -L -o main.zip +# Set build arg for latest release URL (optional) +ARG LATEST_RELEASE + +# Download the latest release - if LATEST_RELEASE is provided use it, otherwise fetch from API +RUN if [ -n "$LATEST_RELEASE" ]; then \ + echo "Using provided release URL" && \ + curl -L -o main.zip "${LATEST_RELEASE}"; \ + else \ + echo "Fetching latest release URL" && \ + curl -s https://api.github.com/repos/stacklok/codegate-ui/releases/latest | \ + jq -r '.zipball_url' | xargs curl -L -o main.zip; \ + fi # Extract the downloaded zip file RUN unzip main.zip