Add support for WSL local dev (#1756)
Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
This commit is contained in:
parent
7376ada1b1
commit
e7c465eaae
|
|
@ -5,7 +5,7 @@ COPY ./build /var/www/appsmith
|
|||
EXPOSE 80
|
||||
# This is the default nginx template file inside the container.
|
||||
# This is replaced by the install.sh script during a deployment
|
||||
COPY ./docker/templates/nginx-linux.conf.template /nginx.conf.template
|
||||
COPY ./docker/templates/nginx-app.conf.template /nginx.conf.template
|
||||
COPY ./docker/templates/nginx-root.conf.template /nginx-root.conf.template
|
||||
# This is the script that is used to start Nginx when the Docker container starts
|
||||
COPY ./docker/start-nginx.sh /start-nginx.sh
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ serve -s build -p 3000 &
|
|||
|
||||
# Substitute all the env variables in nginx
|
||||
vars_to_substitute=$(printf '\$%s,' $(env | grep -o "^APPSMITH_[A-Z0-9_]\+" | xargs))
|
||||
cat ./docker/templates/nginx-linux.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf
|
||||
cat ./docker/templates/nginx-app.conf.template | sed -e "s|__APPSMITH_CLIENT_PROXY_PASS__|http://localhost:3000|g" | sed -e "s|__APPSMITH_SERVER_PROXY_PASS__|http://localhost:8080|g" | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf
|
||||
cat ./docker/templates/nginx-root.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx-root.conf
|
||||
|
||||
# Create the SSL files for Nginx. Required for service workers to work properly.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
# This script is baked into the appsmith-editor Dockerfile and is used to boot Nginx when the Docker container starts
|
||||
# Refer: /app/client/Dockerfile
|
||||
set -ue
|
||||
cat /nginx.conf.template | envsubst "$(printf '$%s,' $(env | grep -Eo '^APPSMITH_[A-Z0-9_]+'))" | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > /etc/nginx/conf.d/default.conf
|
||||
cat /nginx.conf.template | sed -e "s|__APPSMITH_CLIENT_PROXY_PASS__|http://localhost:3000|g" | sed -e "s|__APPSMITH_SERVER_PROXY_PASS__|http://localhost:8080|g" | envsubst "$(printf '$%s,' $(env | grep -Eo '^APPSMITH_[A-Z0-9_]+'))" | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > /etc/nginx/conf.d/default.conf
|
||||
cat /nginx-root.conf.template | envsubst "$(printf '$%s,' $(env | grep -Eo '^APPSMITH_[A-Z0-9_]+'))" | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > /etc/nginx/nginx.conf
|
||||
exec nginx -g 'daemon off;'
|
||||
|
|
|
|||
|
|
@ -24,10 +24,9 @@ server {
|
|||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
|
||||
|
||||
sub_filter_once off;
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_pass __APPSMITH_CLIENT_PROXY_PASS__;
|
||||
sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}';
|
||||
sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}';
|
||||
sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}';
|
||||
|
|
@ -57,19 +56,19 @@ server {
|
|||
location /api {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_pass __APPSMITH_SERVER_PROXY_PASS__;
|
||||
}
|
||||
|
||||
location /oauth2 {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_pass __APPSMITH_SERVER_PROXY_PASS__;
|
||||
}
|
||||
|
||||
location /login {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_pass __APPSMITH_SERVER_PROXY_PASS__;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name dev.appsmith.com;
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name dev.appsmith.com;
|
||||
client_max_body_size 10m;
|
||||
|
||||
ssl_certificate /etc/certificate/dev.appsmith.com.pem;
|
||||
ssl_certificate_key /etc/certificate/dev.appsmith.com-key.pem;
|
||||
|
||||
# include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
gzip on;
|
||||
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Accept-Encoding "";
|
||||
|
||||
index index.html index.htm;
|
||||
|
||||
sub_filter_once off;
|
||||
location / {
|
||||
proxy_pass http://host.docker.internal:3000;
|
||||
sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}';
|
||||
sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}';
|
||||
sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}';
|
||||
sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}';
|
||||
sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '${APPSMITH_MARKETPLACE_ENABLED}';
|
||||
sub_filter __APPSMITH_SEGMENT_KEY__ '${APPSMITH_SEGMENT_KEY}';
|
||||
sub_filter __APPSMITH_OPTIMIZELY_KEY__ '${APPSMITH_OPTIMIZELY_KEY}';
|
||||
sub_filter __APPSMITH_ALGOLIA_API_ID__ '${APPSMITH_ALGOLIA_API_ID}';
|
||||
sub_filter __APPSMITH_ALGOLIA_SEARCH_INDEX_NAME__ '${APPSMITH_ALGOLIA_SEARCH_INDEX_NAME}';
|
||||
sub_filter __APPSMITH_ALGOLIA_API_KEY__ '${APPSMITH_ALGOLIA_API_KEY}';
|
||||
sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '${APPSMITH_CLIENT_LOG_LEVEL}';
|
||||
sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '${APPSMITH_GOOGLE_MAPS_API_KEY}';
|
||||
sub_filter __APPSMITH_TNC_PP__ '${APPSMITH_TNC_PP}';
|
||||
sub_filter __APPSMITH_SENTRY_RELEASE__ '${APPSMITH_SENTRY_RELEASE}';
|
||||
sub_filter __APPSMITH_SENTRY_ENVIRONMENT__ '${APPSMITH_SENTRY_ENVIRONMENT}';
|
||||
sub_filter __APPSMITH_VERSION_ID__ '${APPSMITH_VERSION_ID}';
|
||||
sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}';
|
||||
sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}';
|
||||
sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}';
|
||||
sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}';
|
||||
}
|
||||
|
||||
|
||||
location /f {
|
||||
proxy_pass https://cdn.optimizely.com/;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_pass http://host.docker.internal:8080;
|
||||
}
|
||||
|
||||
location /oauth2 {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
proxy_pass http://host.docker.internal:8080;
|
||||
}
|
||||
|
||||
location /login {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
proxy_pass http://host.docker.internal:8080;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,16 +43,41 @@ else
|
|||
export $(grep -v '^[[:space:]]*#' ${ENV_FILE} | xargs)
|
||||
fi
|
||||
|
||||
unameOut="$(uname -s)"
|
||||
# Stop and remove existing container
|
||||
# Ignore outcome in case someone decides to set -e later
|
||||
docker rm -f wildcard-nginx || true
|
||||
|
||||
|
||||
default_server_proxy="http://host.docker.internal:8080"
|
||||
default_client_proxy="http://host.docker.internal:3000"
|
||||
|
||||
default_linux_server_proxy="http://localhost:8080"
|
||||
default_linux_client_proxy="http://localhost:3000"
|
||||
|
||||
# default server to internal docker
|
||||
server_proxy_pass="${1:-$default_server_proxy}"
|
||||
|
||||
uname_out="$(uname -s)"
|
||||
vars_to_substitute="$(printf '\$%s,' $(grep -o "^APPSMITH_[A-Z0-9_]\+" ../../.env | xargs))"
|
||||
case "${unameOut}" in
|
||||
client_proxy_pass="${default_client_proxy}"
|
||||
network_mode="bridge"
|
||||
case "${uname_out}" in
|
||||
Linux*) machine=Linux
|
||||
# If we're not in WSL, use the mode that works
|
||||
if [[ "$(< /proc/version)" != *@(icrosoft|WSL)* ]]; then
|
||||
network_mode="host"
|
||||
client_proxy_pass=$default_linux_client_proxy
|
||||
# if no server was passed
|
||||
if [[ -z $1 ]]; then
|
||||
server_proxy_pass=$default_linux_server_proxy
|
||||
fi
|
||||
fi
|
||||
echo "
|
||||
Starting nginx for Linux...
|
||||
"
|
||||
cat ./docker/templates/nginx-linux.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf &&
|
||||
cat ./docker/templates/nginx-app.conf.template | sed -e "s|__APPSMITH_CLIENT_PROXY_PASS__|${client_proxy_pass}|g" | sed -e "s|__APPSMITH_SERVER_PROXY_PASS__|${server_proxy_pass}|g" | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf &&
|
||||
cat ./docker/templates/nginx-root.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx-root.conf &&
|
||||
sudo docker run --network host --name wildcard-nginx -d -p 80:80 -p 443:443 -v `pwd`/docker/nginx-root.conf:/etc/nginx/nginx.conf -v `pwd`/docker/nginx.conf:/etc/nginx/conf.d/app.conf -v `pwd`/docker/_wildcard.appsmith.com.pem:/etc/certificate/dev.appsmith.com.pem -v `pwd`/docker/_wildcard.appsmith.com-key.pem:/etc/certificate/dev.appsmith.com-key.pem nginx:latest \
|
||||
sudo docker run --network ${network_mode} --name wildcard-nginx -d -p 80:80 -p 443:443 -v `pwd`/docker/nginx-root.conf:/etc/nginx/nginx.conf -v `pwd`/docker/nginx.conf:/etc/nginx/conf.d/app.conf -v `pwd`/docker/_wildcard.appsmith.com.pem:/etc/certificate/dev.appsmith.com.pem -v `pwd`/docker/_wildcard.appsmith.com-key.pem:/etc/certificate/dev.appsmith.com-key.pem nginx:latest \
|
||||
&& echo "
|
||||
nginx is listening on port 443 and forwarding to port 3000
|
||||
visit https://dev.appsmith.com
|
||||
|
|
@ -62,7 +87,7 @@ case "${unameOut}" in
|
|||
echo "
|
||||
Starting nginx for MacOS...
|
||||
"
|
||||
cat ./docker/templates/nginx-mac.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf &&
|
||||
cat ./docker/templates/nginx-app.conf.template | sed -e "s|__APPSMITH_CLIENT_PROXY_PASS__|${client_proxy_pass}|g" | sed -e "s|__APPSMITH_SERVER_PROXY_PASS__|${server_proxy_pass}|g" | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx.conf &&
|
||||
cat ./docker/templates/nginx-root.conf.template | envsubst ${vars_to_substitute} | sed -e 's|\${\(APPSMITH_[A-Z0-9_]*\)}||g' > ./docker/nginx-root.conf &&
|
||||
docker run --name wildcard-nginx -d -p 80:80 -p 443:443 -v `pwd`/docker/nginx-root.conf:/etc/nginx/nginx.conf -v `pwd`/docker/nginx.conf:/etc/nginx/conf.d/app.conf -v `pwd`/docker/_wildcard.appsmith.com.pem:/etc/certificate/dev.appsmith.com.pem -v `pwd`/docker/_wildcard.appsmith.com-key.pem:/etc/certificate/dev.appsmith.com-key.pem nginx:latest \
|
||||
&& echo "
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user