Skip to content

Serve lowcoder-sdk and lowcoder-comps #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,31 @@ CMD [ "/bin/sh", "/lowcoder/node-service/entrypoint.sh" ]
## Build lowcoder client application
##
FROM node:20.2-slim AS build-client
COPY ./client /lowcoder-client
WORKDIR /lowcoder-client
RUN yarn --immutable

# TODO: build lowcoder-comps

# curl is required for yarn build to succeed, because it calls it while building client
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates

# Build client
COPY ./client /lowcoder-client
WORKDIR /lowcoder-client
RUN yarn --immutable

ARG REACT_APP_COMMIT_ID=test
ARG REACT_APP_ENV=production
ARG REACT_APP_EDITION=community
ARG REACT_APP_DISABLE_JS_SANDBOX=true
RUN yarn build

# Build lowcoder-comps
WORKDIR /lowcoder-client/packages/lowcoder-comps
RUN yarn install
RUN yarn build
RUN tar -zxf lowcoder-comps-*.tgz && mv package lowcoder-comps

# Build lowcoder-sdk
WORKDIR /lowcoder-client/packages/lowcoder-sdk
RUN yarn install
RUN yarn build

##
## Intermediary Lowcoder client image
Expand All @@ -140,8 +150,13 @@ RUN usermod --login lowcoder --uid 9001 nginx \
&& rm -f /etc/nginx/nginx.conf \
&& mkdir -p /lowcoder/assets

# Copy lowcoder client data
# Copy lowcoder client
COPY --chown=lowcoder:lowcoder --from=build-client /lowcoder-client/packages/lowcoder/build/ /lowcoder/client
# Copy lowcoder components
COPY --chown=lowcoder:lowcoder --from=build-client /lowcoder-client/packages/lowcoder-comps/lowcoder-comps /lowcoder/client-comps
# Copy lowcoder SDK
COPY --chown=lowcoder:lowcoder --from=build-client /lowcoder-client/packages/lowcoder-sdk /lowcoder/client-sdk


# Copy additional nginx init scripts
COPY deploy/docker/frontend/00-change-nginx-user.sh /docker-entrypoint.d/00-change-nginx-user.sh
Expand All @@ -150,6 +165,7 @@ COPY deploy/docker/frontend/01-update-nginx-conf.sh /docker-entrypoint.d/01-upda
RUN chmod +x /docker-entrypoint.d/00-change-nginx-user.sh && \
chmod +x /docker-entrypoint.d/01-update-nginx-conf.sh

COPY deploy/docker/frontend/server.conf /etc/nginx/server.conf
COPY deploy/docker/frontend/nginx-http.conf /etc/nginx/nginx-http.conf
COPY deploy/docker/frontend/nginx-https.conf /etc/nginx/nginx-https.conf
COPY deploy/docker/frontend/ssl-certificate.conf /etc/nginx/ssl-certificate.conf
Expand Down
6 changes: 3 additions & 3 deletions deploy/docker/frontend/01-update-nginx-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ else
ln -s /etc/nginx/nginx-http.conf /etc/nginx/nginx.conf
fi;

sed -i "s@__LOWCODER_MAX_QUERY_TIMEOUT__@${LOWCODER_MAX_QUERY_TIMEOUT:=120}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_MAX_REQUEST_SIZE__@${LOWCODER_MAX_REQUEST_SIZE:=20m}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_API_SERVICE_URL__@${LOWCODER_API_SERVICE_URL:=http://localhost:8080}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_NODE_SERVICE_URL__@${LOWCODER_NODE_SERVICE_URL:=http://localhost:6060}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_MAX_QUERY_TIMEOUT__@${LOWCODER_MAX_QUERY_TIMEOUT:=120}@" /etc/nginx/server.conf
sed -i "s@__LOWCODER_API_SERVICE_URL__@${LOWCODER_API_SERVICE_URL:=http://localhost:8080}@" /etc/nginx/server.conf
sed -i "s@__LOWCODER_NODE_SERVICE_URL__@${LOWCODER_NODE_SERVICE_URL:=http://localhost:6060}@" /etc/nginx/server.conf

echo "nginx config updated with:"
echo " Lowcoder max upload size: ${LOWCODER_MAX_REQUEST_SIZE:=20m}"
Expand Down
32 changes: 1 addition & 31 deletions deploy/docker/frontend/nginx-http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,7 @@ http {

server {
listen 3000 default_server;
root /lowcoder/client;

proxy_connect_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_send_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_read_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;

location / {
try_files $uri /index.html;

if ($request_filename ~* .*.(html|htm)$) {
add_header Cache-Control no-cache;
}
}

location /assets {
alias /lowcoder/assets;
expires 1M;
}

location /api {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_API_SERVICE_URL__;
}

location /node-service/plugin-icons {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_NODE_SERVICE_URL__;
}
include /etc/nginx/server.conf;
}
}
32 changes: 1 addition & 31 deletions deploy/docker/frontend/nginx-https.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,11 @@ http {

server {
listen 3443 ssl;
root /lowcoder/client;

include /etc/nginx/ssl-certificate.conf;
include /etc/nginx/ssl-params.conf;

proxy_connect_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_send_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_read_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;

location / {
try_files $uri /index.html;

if ($request_filename ~* .*.(html|htm)$) {
add_header Cache-Control no-cache;
}
}

location /assets {
alias /lowcoder/assets;
expires 1M;
}

location /api {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_API_SERVICE_URL__;
}

location /node-service/plugin-icons {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_NODE_SERVICE_URL__;
}
include /etc/nginx/server.conf;
}

}
49 changes: 49 additions & 0 deletions deploy/docker/frontend/server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
root /lowcoder/client;

proxy_connect_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_send_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_read_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;

location / {
try_files $uri /index.html;

if ($request_filename ~* .*.(html|htm)$) {
add_header Cache-Control no-cache;
}
}

location /sdk {
try_files $uri =404;

alias /lowcoder/client-sdk;
expires 1M;
}

location /comps {
try_files $uri =404;

alias /lowcoder/client-comps;
expires 1M;
}

location /assets {
try_files $uri =404;

alias /lowcoder/assets;
expires 1M;
}

location /api {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_API_SERVICE_URL__;
}

location /node-service/plugin-icons {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass __LOWCODER_NODE_SERVICE_URL__;
}

Loading