docker: improve image layout and backend-only/frontend-only images (#2071)
* docker: improve image layout and backend-only image * add tests * add tests * add frontend * add frontend * label * fix
This commit is contained in:
parent
b74dd3fa7d
commit
ba59a9f449
9 changed files with 233 additions and 48 deletions
27
docker/frontend/build_and_push_frontend.Dockerfile
Normal file
27
docker/frontend/build_and_push_frontend.Dockerfile
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Keep this syntax directive! It's used to enable Docker BuildKit
|
||||
|
||||
################################
|
||||
# BUILDER-BASE
|
||||
################################
|
||||
FROM node:lts-bookworm-slim as builder-base
|
||||
COPY src/frontend /frontend
|
||||
|
||||
RUN cd /frontend && npm install && npm run build
|
||||
|
||||
################################
|
||||
# RUNTIME
|
||||
################################
|
||||
FROM nginxinc/nginx-unprivileged:stable-bookworm-perl as runtime
|
||||
|
||||
LABEL org.opencontainers.image.title=langflow-frontend
|
||||
LABEL org.opencontainers.image.authors=['Langflow']
|
||||
LABEL org.opencontainers.image.licenses=MIT
|
||||
LABEL org.opencontainers.image.url=https://github.com/langflow-ai/langflow
|
||||
LABEL org.opencontainers.image.source=https://github.com/langflow-ai/langflow
|
||||
|
||||
COPY --from=builder-base --chown=nginx /frontend/build /usr/share/nginx/html
|
||||
COPY --chown=nginx ./docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --chown=nginx ./docker/frontend/start-nginx.sh /start-nginx.sh
|
||||
RUN chmod +x /start-nginx.sh
|
||||
ENTRYPOINT ["/start-nginx.sh"]
|
||||
22
docker/frontend/nginx.conf
Normal file
22
docker/frontend/nginx.conf
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
server {
|
||||
gzip on;
|
||||
gzip_comp_level 2;
|
||||
gzip_min_length 1000;
|
||||
gzip_types text/xml text/css;
|
||||
gzip_http_version 1.1;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [4-6] \.";
|
||||
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
}
|
||||
location /api {
|
||||
proxy_pass __BACKEND_URL__;
|
||||
}
|
||||
|
||||
include /etc/nginx/extra-conf.d/*.conf;
|
||||
}
|
||||
16
docker/frontend/start-nginx.sh
Normal file
16
docker/frontend/start-nginx.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
trap 'kill -TERM $PID' TERM INT
|
||||
if [ -z "$BACKEND_URL" ]; then
|
||||
BACKEND_URL="$1"
|
||||
fi
|
||||
if [ -z "$BACKEND_URL" ]; then
|
||||
echo "BACKEND_URL must be set as an environment variable or as first parameter. (e.g. http://localhost:7860)"
|
||||
exit 1
|
||||
fi
|
||||
sed -i "s|__BACKEND_URL__|$BACKEND_URL|g" /etc/nginx/conf.d/default.conf
|
||||
cat /etc/nginx/conf.d/default.conf
|
||||
|
||||
|
||||
# Start nginx
|
||||
exec nginx -g 'daemon off;'
|
||||
Loading…
Add table
Add a link
Reference in a new issue