Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit fddcc71

Browse files
author
Luke Hinds
committed
Fix cert deploy
1 parent 6022c2e commit fddcc71

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

Dockerfile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3232

3333
WORKDIR /usr/src/
3434

35-
# Get the latest commit sha as a build arg
36-
# This is needed otherwise Docker will cache the git clone step. With this workaround
37-
# we can force Docker to re-run the git clone step if the latest commit sha changes.
38-
# --build-arg LATEST_COMMIT_SHA=$(curl \
39-
# -LSsk "https://api.github.com/repos/stacklok/codegate-ui/commits?per_page=1" \
40-
# -H "Authorization: Bearer $GH_CI_TOKEN" | jq -r '.[0].sha')
41-
ARG LATEST_COMMIT_SHA=LATEST
42-
RUN echo "Latest FE commit: $LATEST_COMMIT_SHA"
43-
# Download the webapp from GH
44-
# -L to follow redirects
35+
# Get the latest release of the webapp from GH
4536
RUN --mount=type=secret,id=gh_token \
46-
LATEST_COMMIT_SHA=${LATEST_COMMIT_SHA} \
47-
curl -L -o main.zip "https://api.github.com/repos/stacklok/codegate-ui/zipball/main" \
48-
-H "Authorization: Bearer $(cat /run/secrets/gh_token)"
37+
curl -s -H "Authorization: Bearer $(cat /run/secrets/gh_token)" https://api.github.com/repos/stacklok/codegate-ui/releases/latest \
38+
| grep '"zipball_url":' \
39+
| cut -d '"' -f 4 \
40+
| xargs -n 1 -I {} curl -L -H "Authorization: Bearer $(cat /run/secrets/gh_token)" -o main.zip {}
4941

5042
# Extract the downloaded zip file
5143
RUN unzip main.zip

scripts/entrypoint.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,31 @@ BACKUP_NAME="backup"
66
MODEL_BASE_PATH="/app/codegate_volume/models"
77
CODEGATE_DB_FILE="/app/codegate_volume/db/codegate.db"
88
CODEGATE_CERTS="/app/codegate_volume/certs"
9-
WEBAPP="/usr/src/webapp"
9+
NGINX_CA_CERT="/usr/share/nginx/html/certificates"
10+
11+
# Function to ensure the certificates directory exists and copy the certificate
12+
setup_certificate() {
13+
echo "Ensuring the Nginx certificates directory exists..."
14+
mkdir -p "$NGINX_CA_CERT" # Ensure the directory exists
15+
16+
# Check if the source certificate exists
17+
if [ ! -f "$CODEGATE_CERTS/ca.crt" ]; then
18+
echo "Error: Certificate file not found at $CODEGATE_CERTS/ca.crt"
19+
exit 1
20+
fi
21+
22+
echo "Copying CA certificate to $NGINX_CA_CERT..."
23+
cp "$CODEGATE_CERTS/ca.crt" "$NGINX_CA_CERT/codegate_ca.crt"
24+
25+
# Verify the copy was successful
26+
if [ -f "$NGINX_CA_CERT/codegate_ca.crt" ]; then
27+
echo "CA certificate successfully copied to $NGINX_CA_CERT"
28+
else
29+
echo "Error: Failed to copy CA certificate."
30+
exit 1
31+
fi
32+
}
33+
1034

1135
# Function to restore backup if paths are provided
1236
restore_backup() {
@@ -64,7 +88,7 @@ restore_backup
6488
genrerate_certs
6589

6690
# Step 3: Make CA available to UI
67-
cp "$CODEGATE_CERTS/ca.crt" "$WEBAPP/public/certificates/codegate_ca.crt"
91+
setup_certificate
6892

6993
# Step 4: Start the dashboard
7094
start_dashboard

0 commit comments

Comments
 (0)