Skip to content

Commit

Permalink
Merge pull request #504 from stacklok/fix-image
Browse files Browse the repository at this point in the history
Fix release download
  • Loading branch information
lukehinds authored Jan 7, 2025
2 parents fe5a19e + cb433e2 commit b91cb8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,29 @@ 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\
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.
# Set build arg for latest release URL (optional)
ARG LATEST_RELEASE

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 - 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
Expand Down Expand Up @@ -111,4 +120,4 @@ USER codegate

# Set the container's default entrypoint
EXPOSE 8989
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
ENTRYPOINT ["/app/scripts/entrypoint.sh"]

0 comments on commit b91cb8d

Please sign in to comment.