Skip to content

Commit

Permalink
#581 IS_DOCKER and fix titiler paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Sep 27, 2024
1 parent 981f447 commit f1dc5d4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions configuration/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function getClientEnvironment(publicUrl) {
MAIN_MISSION: process.env.MAIN_MISSION,
THIRD_PARTY_COOKIES: process.env.THIRD_PARTY_COOKIES || "",
SKIP_CLIENT_INITIAL_LOGIN: process.env.SKIP_CLIENT_INITIAL_LOGIN || "",
IS_DOCKER: process.env.IS_DOCKER,
}
);
// Stringify all values so we can feed into webpack DefinePlugin
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h db -p 5432 && uvicorn stac_fastapi.pgstac.app:app --host 0.0.0.0 --port 8881"
volumes:
- ./adjacent-servers/docker-scripts:/tmp/scripts
- ./Missions:/usr/src/app/Missions
- ./Missions:/app/Missions

tipg:
image: ghcr.io/developmentseed/tipg:0.7.1
Expand Down Expand Up @@ -58,7 +58,7 @@ services:
- db
volumes:
- ./adjacent-servers/docker-scripts:/tmp/scripts
- ./Missions:/usr/src/app/Missions
- ./Missions:/app/Missions

titiler:
# TODO: remove once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved
Expand Down Expand Up @@ -102,7 +102,7 @@ services:
# rio-tiler config
# - RIO_TILER_MAX_THREADS=
volumes:
- ./Missions:/usr/src/app/Missions
- ./Missions:/app/Missions

titiler-pgstac:
# At the time of writing, rasterio and psycopg wheels are not available for arm64 arch
Expand Down Expand Up @@ -150,7 +150,7 @@ services:
- db
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h db -p 5432 && /start.sh"
volumes:
- ./Missions:/usr/src/app/Missions
- ./Missions:/app/Missions
- ./adjacent-servers/docker-scripts:/tmp/scripts

db:
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
mmgisglobal.MAIN_MISSION = "#{MAIN_MISSION}";
mmgisglobal.SKIP_CLIENT_INITIAL_LOGIN = "#{SKIP_CLIENT_INITIAL_LOGIN}";
mmgisglobal.THIRD_PARTY_COOKIES = "#{THIRD_PARTY_COOKIES}";
mmgisglobal.IS_DOCKER = "#{IS_DOCKER}";
break;
default:
mmgisglobal.AUTH = "%AUTH%";
Expand All @@ -358,6 +359,7 @@
mmgisglobal.MAIN_MISSION = "%MAIN_MISSION%";
mmgisglobal.SKIP_CLIENT_INITIAL_LOGIN = "%SKIP_CLIENT_INITIAL_LOGIN%";
mmgisglobal.THIRD_PARTY_COOKIES = "%THIRD_PARTY_COOKIES%";
mmgisglobal.IS_DOCKER = "%IS_DOCKER%";
// eslint-disable-next-line
mmgisglobal.HOSTS = %HOSTS%;
break;
Expand Down
4 changes: 3 additions & 1 deletion scripts/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const rootDir = `${__dirname}/..`;
const app = express();

const isDocker = utils.isDocker();
process.env.IS_DOCKER = isDocker ? "true" : "false";

const apilimiter = rateLimit({
windowMs: 5 * 60 * 1000, // 5 minutes
Expand Down Expand Up @@ -936,7 +937,7 @@ setups.getBackendSetups(function (setups) {
let permission = "000";
if (process.env.AUTH === "csso") permission = "001";
if (req.session.permission) permission = req.session.permission;

console.log("process.env.IS_DOCKER", process.env.IS_DOCKER);
const groups = req.groups ? Object.keys(req.groups) : [];
res.render("../build/index.pug", {
user: user,
Expand All @@ -949,6 +950,7 @@ setups.getBackendSetups(function (setups) {
CLEARANCE_NUMBER: process.env.CLEARANCE_NUMBER,
ENABLE_MMGIS_WEBSOCKETS: process.env.ENABLE_MMGIS_WEBSOCKETS,
MAIN_MISSION: process.env.MAIN_MISSION,
IS_DOCKER: "test",
SKIP_CLIENT_INITIAL_LOGIN: process.env.SKIP_CLIENT_INITIAL_LOGIN,
THIRD_PARTY_COOKIES: process.env.THIRD_PARTY_COOKIES,
PORT: process.env.PORT,
Expand Down
18 changes: 13 additions & 5 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,21 @@ const L_ = {
let nextUrl = url
if (!F_.isUrlAbsolute(nextUrl)) {
nextUrl = L_.missionPath + nextUrl
if (type === 'tile') {
if (layerData && layerData.throughTileServer === true)
nextUrl = `../../${nextUrl}`
}
if (
type === 'tile' &&
layerData &&
layerData.throughTileServer === true
) {
if (
!F_.isUrlAbsolute(nextUrl) &&
window.mmgisglobal.IS_DOCKER !== 'true'
) {
nextUrl = `../../${nextUrl}`
}
if (layerData && layerData.throughTileServer === true)
nextUrl = `${window.location.origin}/titiler/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.webp?url=${nextUrl}`
}
if (layerData && layerData.throughTileServer === true)
nextUrl = `${window.location.origin}/titiler/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.webp?url=${nextUrl}`
return nextUrl
},
//Takes in config layer obj
Expand Down

0 comments on commit f1dc5d4

Please sign in to comment.