@@ -21,29 +21,78 @@ RUN poetry config virtualenvs.create false && \
21
21
# Copy the rest of the application
22
22
COPY . /app
23
23
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
+
24
56
# Runtime stage: Create the final lightweight image
25
57
FROM python:3.12-slim AS runtime
26
58
27
59
# Install runtime system dependencies
28
60
RUN apt-get update && apt-get install -y --no-install-recommends \
29
61
libgomp1 \
62
+ nginx \
30
63
&& rm -rf /var/lib/apt/lists/*
31
64
32
- # Create a non-root user and switch to it
65
+
66
+ # Create a non-root user
33
67
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
34
75
USER codegate
35
76
WORKDIR /app
36
77
37
78
# Copy necessary artifacts from the builder stage
38
79
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
39
80
COPY --from=builder /app /app
40
81
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
+
41
87
# Set the PYTHONPATH environment variable
42
88
ENV PYTHONPATH=/app/src
43
89
44
90
# Allow to expose weaviate_data volume
45
91
VOLUME ["/app/weaviate_data" ]
46
92
47
- # Set the container's default entrypoint
93
+ # Set the container's default entrypoint to run Codegate BE and FE
48
94
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