Fixes nginx stupid. Adds back deploy url. Totally refactors docker-compose.

This commit is contained in:
Aaron Louie 2020-05-26 14:48:31 -04:00
parent 650bb8f6f1
commit 47d1c7fe88
5 changed files with 73 additions and 69 deletions

View File

@ -24,11 +24,14 @@ COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
# Fix for Angular routing
RUN echo "pushstate: enabled" > /etc/nginx/html/Staticfile
# The entrypoint.sh script will run after the container finishes starting.
# Substitutes environment variables in nginx configuration and index.html,
# then starts/reloads nginx.
ENTRYPOINT ["./entrypoint.sh", \
"/etc/nginx/html/index.html,/etc/nginx/conf.d/default.conf", \
"PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,PORT0", \
"PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0", \
"/etc/nginx/html", \
"true"]

View File

@ -2,81 +2,70 @@ version: "3.3"
services:
db:
container_name: db
image: sartography/cr-connect-db:$E2E_TAG
image: sartography/cr-connect-db:dev
ports:
- "5432:5432"
environment:
- POSTGRES_USER=crc_user
- POSTGRES_PASSWORD=crc_pass
- POSTGRES_MULTIPLE_DATABASES=crc_test,crc_dev,pb_test,pb
- POSTGRES_USER=rrt_user
- POSTGRES_PASSWORD=rrt_pass
- POSTGRES_MULTIPLE_DATABASES=rrt
healthcheck:
test: ["CMD", "pg_isready"]
timeout: 20s
retries: 10
pb:
container_name: pb
depends_on:
- db
image: sartography/protocol-builder-mock:$E2E_TAG
environment:
- UPGRADE_DB=true
- DB_HOST=db
- DB_PORT=5432
- DB_PASSWORD=crc_pass
- DB_USER=crc_user
- DB_NAME=pb_test
- PORT0=5001
- APPLICATION_ROOT=/
- CORS_ALLOW_ORIGINS=localhost:5000,backend:5000
ports:
- "5001:5001"
command: ./wait-for-it.sh db:5432 -t 0 -- ./docker_run.sh
ldap:
container_name: ldap
image: tuxmonteiro/ldap-mock
ports:
- "3890"
backend:
container_name: backend
depends_on:
- db
- pb
- ldap
image: sartography/cr-connect-workflow:$E2E_TAG
image: sartography/cr-connect-workflow:dev
environment:
- UPGRADE_DB=true
- RESET_DB=true
- LDAP_URL=ldap:3890
- PB_BASE_URL=http://pb:5001/v2.0/
- DB_HOST=db
- DB_PORT=5432
- DB_PASSWORD=crc_pass
- DB_USER=crc_user
- DB_NAME=crc_test
- PORT0=5000
- APPLICATION_ROOT=/
- APPLICATION_ROOT=/api
- CORS_ALLOW_ORIGINS=localhost:5002,bpmn:5002,localhost:4200,frontend:4200
- DB_HOST=db
- DB_NAME=rrt
- DB_PASSWORD=rrt_pass
- DB_PORT=5432
- DB_USER=rrt_user
- LDAP_URL=ldap.virginia.edu
- PB_ENABLED=false
- PORT0=5000
- RESET_DB=true
- UPGRADE_DB=true
ports:
- "5000:5000"
command: ./wait-for-it.sh pb:5001 -t 0 -- ./docker_run.sh
command: ./wait-for-it.sh db:5432 -t 0 -- ./docker_run.sh
# # Uncomment for debugging
# bpmn:
# container_name: bpmn
# depends_on:
# - db
# - pb
# - ldap
# - backend
# image: sartography/cr-connect-bpmn:$E2E_TAG
# environment:
# - API_URL=http://localhost:5000/v1.0
# - BASE_HREF=/
# - HOME_ROUTE=home
# - IRB_URL=http://localhost:5001/
# - PORT0=5002
# - PRODUCTION=false
# ports:
# - "5002:5002"
bpmn:
container_name: bpmn
depends_on:
- db
- backend
image: bpmn:local
# image: sartography/cr-connect-bpmn:dev
environment:
- API_URL=http://localhost:5000/api/v1.0
- BASE_HREF=/bpmn/
- DEPLOY_URL=/bpmn/
- HOME_ROUTE=home
- PORT0=5002
- PRODUCTION=false
ports:
- "5002:5002"
frontend:
container_name: frontend
depends_on:
- db
- backend
image: frontend:local
# image: sartography/cr-connect-frontend:dev
environment:
- API_URL=http://localhost:5000/api/v1.0
- BASE_HREF=/app/
- DEPLOY_URL=/app/
- HOME_ROUTE=home
- PORT0=4200
- PRODUCTION=false
ports:
- "4200:4200"

View File

@ -43,12 +43,17 @@ else
fi
# Find & replace BASE_HREF in all files in the nginx html directory
if [[ "$2" == *"BASE_HREF"* ]]; then
if [[ "$2" == *"BASE_HREF"* ]] && [[ "$2" == *"DEPLOY_URL"* ]]; then
# Add trailing slash to $BASE_HREF if needed
length=${#BASE_HREF}
last_char=${BASE_HREF:length-1:1}
[[ $last_char != "/" ]] && BASE_HREF="$BASE_HREF/"; :
# Add trailing slash to $DEPLOY_URL if needed
length=${#DEPLOY_URL}
last_char=${DEPLOY_URL:length-1:1}
[[ $last_char != "/" ]] && DEPLOY_URL="$DEPLOY_URL/"; :
# The third parameter is the absolute path to the nginx html directory
if [[ $num_args -ge 3 ]]; then
# Replace all instances of __REPLACE_ME_WITH_BASE_HREF__ with $BASE_HREF
@ -58,6 +63,14 @@ if [[ "$2" == *"BASE_HREF"* ]]; then
echo 'Replacing base href...'
# Wait a few seconds in case find | sed needs more time
sleep 3
# Replace all instances of __REPLACE_ME_WITH_DEPLOY_URL__ with $DEPLOY_URL
find "$3" \( -type d -name .git -prune \) -o -type f -print0 | \
xargs -0 sed -i 's@__REPLACE_ME_WITH_DEPLOY_URL__@'"$DEPLOY_URL"'@g'
echo 'Replacing deploy url...'
# Wait a few seconds in case find | sed needs more time
sleep 3
fi
fi

View File

@ -2,11 +2,10 @@ server {
listen $PORT0;
location $BASE_HREF/ {
root /etc/nginx/html;
alias /etc/nginx/html/;
index index.html index.htm;
try_files $uri$args $uri$args/ $BASE_HREF/index.html =404;
try_files $uri$args $uri$args/ $uri $uri/ $BASE_HREF/index.html;
rewrite ^([^.]*[^/])$ $1/ permanent;
}
include /etc/nginx/extra-conf.d/*.conf;
}

View File

@ -5,8 +5,8 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --configuration=production --prod --base-href=__REPLACE_ME_WITH_BASE_HREF__",
"build:staging": "ng build --configuration=staging --prod --base-href=__REPLACE_ME_WITH_BASE_HREF__",
"build:prod": "ng build --configuration=production --prod --base-href=__REPLACE_ME_WITH_BASE_HREF__ --deploy-url=__REPLACE_ME_WITH_DEPLOY_URL__",
"build:staging": "ng build --configuration=staging --prod --base-href=__REPLACE_ME_WITH_BASE_HREF__ --deploy-url=__REPLACE_ME_WITH_DEPLOY_URL__",
"build:test": "ng build --configuration=test",
"test": "ng test",
"test:coverage": "ng test --codeCoverage=true --watch=false --browsers=ChromeHeadless",