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

Commit 8c7ca22

Browse files
Download FE repo in Dockerfile
1 parent d54612c commit 8c7ca22

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

.github/workflows/image-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ jobs:
3030
push: false # Only attempt to build, to verify the Dockerfile is working
3131
load: true
3232
cache-from: type=gha
33-
cache-to: type=gha,mode=max
33+
cache-to: type=gha,mode=max
34+
secrets: |
35+
gh_token=${{ secrets.GITHUB_TOKEN }}

.github/workflows/image-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ jobs:
7474
labels: ${{ steps.docker-metadata.outputs.labels }}
7575
cache-from: type=gha
7676
cache-to: type=gha,mode=max
77+
secrets: |
78+
gh_token=${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,78 @@ RUN poetry config virtualenvs.create false && \
2121
# Copy the rest of the application
2222
COPY . /app
2323

24+
# Build the webapp
25+
FROM node:20.18-slim AS webbuilder
26+
27+
# Install curl for downloading the webapp from GH and unzip to extract it
28+
RUN apt-get update && apt-get install -y --no-install-recommends \
29+
curl \
30+
unzip
31+
32+
WORKDIR /usr/src/
33+
34+
# Download the webapp from GH
35+
# -O to save the file with the same name as the remote file
36+
# -L to follow redirects
37+
# -s to silence the progress bar
38+
# -k to allow curl to make insecure connections
39+
# -H to pass the GITHUB_TOKEN as a header
40+
RUN --mount=type=secret,id=gh_token \
41+
curl -OLSsk "https://github.com/stacklok/codegate-ui/archive/refs/heads/main.zip" \
42+
-H "Authorization: Bearer $(cat /run/secrets/gh_token)"
43+
44+
# Extract the downloaded zip file
45+
RUN unzip main.zip
46+
RUN rm main.zip
47+
# Rename the extracted folder
48+
RUN mv codegate-ui-main webapp
49+
50+
WORKDIR /usr/src/webapp
51+
52+
# Install the webapp dependencies and build it
53+
RUN npm install
54+
RUN npm run build
55+
2456
# Runtime stage: Create the final lightweight image
2557
FROM python:3.12-slim AS runtime
2658

2759
# Install runtime system dependencies
2860
RUN apt-get update && apt-get install -y --no-install-recommends \
2961
libgomp1 \
62+
nginx \
3063
&& rm -rf /var/lib/apt/lists/*
3164

32-
# Create a non-root user and switch to it
65+
66+
# Create a non-root user
3367
RUN adduser --system --no-create-home codegate --uid 1000
68+
69+
# Set permissions for user codegate to run nginx
70+
RUN chown -R codegate /var/lib/nginx && \
71+
chown -R codegate /var/log/nginx && \
72+
chown -R codegate /run
73+
74+
# Switch to codegate user
3475
USER codegate
3576
WORKDIR /app
3677

3778
# Copy necessary artifacts from the builder stage
3879
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
3980
COPY --from=builder /app /app
4081

82+
# Copy necessary artifacts from the webbuilder stage
83+
COPY --from=webbuilder /usr/src/webapp/dist /var/www/html
84+
# Expose nginx
85+
EXPOSE 80
86+
4187
# Set the PYTHONPATH environment variable
4288
ENV PYTHONPATH=/app/src
4389

4490
# Allow to expose weaviate_data volume
4591
VOLUME ["/app/weaviate_data"]
4692

47-
# Set the container's default entrypoint
93+
# Set the container's default entrypoint to run Codegate BE and FE
4894
EXPOSE 8989
49-
ENTRYPOINT ["python", "-m", "src.codegate.cli", "serve", "--port", "8989", "--host", "0.0.0.0"]
95+
ENTRYPOINT ["/bin/bash", "-c", " \
96+
python -m src.codegate.cli serve --port 8989 --host 0.0.0.0 & \
97+
nginx -g 'daemon off;' \
98+
"]

0 commit comments

Comments
 (0)