Skip to content
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

Spaceapps #434

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

andresinho20049
Copy link

Purpose

  • run project with docker without difficulties
db:
    image: postgis/postgis:10-2.5-alpine
    env_file: .env
    ports:
      - 5433:5432
    restart: on-failure
    volumes:
      - mmgis-db:/var/lib/postgresql/data
      - ./Database:/usr/src/app/Database
      - ./Database/PgSQL_queries/mmgisDB_queries.sql:/docker-entrypoint-initdb.d/mmgisDB_queries.sql

The base of this image is the postgres image which has a docker entrypoint to start along with the container.

Bash and SQL scripts;

Proposed Changes

  • [ADD] Docker entrypoint with init DB for started config
  • [CHANGE] Run mode for developer

Testing

  • Test Container to integrate and test unit

tariqksoliman and others added 6 commits September 5, 2023 17:28
* Make sure to remove time tab in time disabled

* IFrame examples

* NASA-AMMOS#279 Time Improvements (NASA-AMMOS#280)

* Configure global start end time, Partial local vector time filter

* NASA-AMMOS#279 Time Improvements

* InfoTool checks for links in metadata and renders anchor tags

* Fix environment variable in sample.env for enabling websockets (NASA-AMMOS#281)

* Fix environment variable in sample.env for enabling websockets

* Update docs

* Bug Fix: Don't drawing uncertainty ellipse if either axis is 0

* ts-282 Composite Time Tiles, Time Tiles with range (NASA-AMMOS#283)

* Update Time Tile path structure

* NASA-AMMOS#285 init-db (NASA-AMMOS#286)

* NASA-AMMOS#290 Upgrade config page jquery, fix i closing tag (NASA-AMMOS#291)

* NASA-AMMOS#292 Controlled Time Layers only make initial query, refactored to remove a conflicting setTimeout (NASA-AMMOS#293)

* Fix crash when Time is completely disabled

* NASA-AMMOS#296 Fix WMS url query (NASA-AMMOS#297)

* NASA-AMMOS#298 TimeUI Pan and Zoom and Improvements (NASA-AMMOS#299)

* NASA-AMMOS#298 Early TimeUI Pan Zoom

* NASA-AMMOS#298 Pan, zoom, steps, modes, mostly done

* TimeUI Improvements and verifications

* NASA-AMMOS#298 Fix Point Play bug

* NASA-AMMOS#298 Final Touchups

* Make marker bearings projection-aware

* Update Docs, Add redundant stopGuests check

* Fix Invalid Date when using deep linked timestamps, improve mmgisAPI docs

* Fix typo

* NASA-AMMOS#294 SameSite None env and login improvements (NASA-AMMOS#302)

* NASA-AMMOS#294 SameSite First pass

* NASA-AMMOS#294 Fix session and use postgres as session store

* Use a default session db port

* NASA-AMMOS#294 Regenerate session on login failure too

* Add feature to reconnect WebSocket from client to server (NASA-AMMOS#295)

* Add materialize-css package

* Update WebSocket on client side

* Double reconnect attempt interval every time websocket reconnection attempt fails

* Update package-lock.json

* Move toast to be ~5 pixels from the right side

* Only show 'Successfully Connected' toast if websocket connection has previously failed

* Fix toast display time

* NASA-AMMOS#304 Fix bug in latest too

* Layer UUIDs (NASA-AMMOS#308)

* NASA-AMMOS#306 UUIDs part 1

* NASA-AMMOS#306 Layer UUIDs UI touchups, still missing Config API

* NASA-AMMOS#306 Layer UUIDs for Config API

* NASA-AMMOS#309 Controlled Raster for initial query only (NASA-AMMOS#311)

* Fix function call order bug in addNewLayer function (NASA-AMMOS#310)

* Account for non-uuid deep link names

* Fix toggleLayer bug (NASA-AMMOS#260)

* Fix Node 18+ build (NASA-AMMOS#312)

* NASA-AMMOS#317 Fix time vectors not applying correctly (NASA-AMMOS#319)

* Fix bug where initially on annotations features have no click events

* Add function to overwrite elements displayed in LegendTool (NASA-AMMOS#320)

* Add function to overwrite elements displayed in LegendTool

* Add more checks to overwriteLegends function

* Add overwriteLegends to mmgisAPI

* NASA-AMMOS#322 Add ROOT_PATH, Deprecate PUBLIC_URL (NASA-AMMOS#323)

* NASA-AMMOS#322 ROOT_PATH, doesn't work fully for /configure yet

* NASA-AMMOS#322 ROOT_PATH for runtime subpaths

* NASA-AMMOS#322 Remove PUBLIC_URL and fix ROOT_PATH css

* Update README.md

* Update README.md

* NASA-AMMOS#324 Configurable Context Menu Actions (NASA-AMMOS#325)

* NASA-AMMOS#324 Coordinates Config Tab Raw Variables

* NASA-AMMOS#324 Configurable context menu actions

* Add docker build workflow

* Make sure user input UUIDs through REST API are unique (NASA-AMMOS#326)

* Make sure user input UUIDs through REST API are unique

* Fix overwriting existing UUID issue

* NASA-AMMOS#327 Assorted UI Improvements (NASA-AMMOS#328)

* NASA-AMMOS#313 Expose as much as possible to the mmgisAPI (NASA-AMMOS#330)

* NASA-AMMOS#313 Add Formulae_

* NASA-AMMOS#313 More F_ docs

* NASA-AMMOS#313 Finish up F_ docs

* NASA-AMMOS#313 mmgisAPI addLayer and removeLayer

* NASA-AMMOS#313 Add logged_in endpoint and early Backend API docs

* NASA-AMMOS#331 Websocket aware configure page (NASA-AMMOS#332)

* NASA-AMMOS#331 Websocket aware configure

* Remove console.log

* Update addLayer and removeLayer endpoints in REST API (NASA-AMMOS#337)

* Working on updating REST API

* Do not update config if there are duplicate or bad UUIDs

* Update docs

* NASA-AMMOS#303 Photosphere Targets and Target Pairing (NASA-AMMOS#340)

* NASA-AMMOS#303 Pairings attachments, photosphere targets not working yet

* NASA-AMMOS#303 AzEl computed markers in Photosphere, deleted old docs

* Add back in swagger docs

* NASA-AMMOS#303 Use originOFfset

* Refactor with the uuid upgrade, Update docs

* NASA-AMMOS#341 Export working config, disable override (NASA-AMMOS#342)

* Add xml2js and proj4 packages. (NASA-AMMOS#343)

* add xml2js

* Fix DrawTool Upload Loading style

* Draw Edit properties

* NASA-AMMOS#335 Feature Request: GetMissions (NASA-AMMOS#345)

* NASA-AMMOS#335 /configure/mission full param

* NASA-AMMOS#335 touchup docs

* Fix typo

* NASA-AMMOS#346 Deep Link additional encodeURI

* Fix missing uuids from configure

* WMS TILESIZE param, features without uncertainty properties won't draw in Map, github link of docs page

* Fix clearOnMapClick function for layers with no fill (NASA-AMMOS#348)

* Fix angleUnit on image attachment

* Optional Info button for projects that need a link to project info NASA-AMMOS#350

* Support existing az el properties for pairing attachments

* Fix bug in Photosphere where points with matching names get stuck

* Add dontFloor to mod function

* Updates to info and help buttons

- Hide info and help icons if a url is not configured
- Default the info button to be off in the configuration
- Change to info icon with a circle

* NASA-AMMOS#352 [New Feature]: DrawTool - Feature Property Templates (NASA-AMMOS#353)

* NASA-AMMOS#352 Templating 1

* NASA-AMMOS#352 Templating 2

* NASA-AMMOS#352 Templating 3

* NASA-AMMOS#352 Update Modal for templating

* NASA-AMMOS#352 Migrate DrawTool Templating

* NASA-AMMOS#352 Templating touchups

* NASA-AMMOS#354 Add MAIN_MISSION ENV (NASA-AMMOS#355)

* Do not append time parameters to wmts tile layers

* Fix configure layer cloning

* Remove typo ; in MAIN_MISSION env

* Remove outdated firefox-specific css fix

* Add blob to default-src csp

* NASA-AMMOS#356 DrawTool Templating - Incrementer field (NASA-AMMOS#357)

* NASA-AMMOS#358 - DrawTool - Grouping editing should only update changed template fields (NASA-AMMOS#359)

* NASA-AMMOS#360 Expose all endpoints to longtermtokens (NASA-AMMOS#362)

* NASA-AMMOS#363 Support file_owner in webhook body. Include body for onFileDelete (NASA-AMMOS#364)

* Fix layer uuids showing up in bottom-right coords

* Expose ToolController_

* NASA-AMMOS#366 Don't copy uuid on layer clone (NASA-AMMOS#367)

* NASA-AMMOS#369 Refresh vector layers, also some WEBSOCKET_ROOT_PATH (NASA-AMMOS#370)

* NASA-AMMOS#368 Fix Websocket usage with ROOT_PATH (NASA-AMMOS#373)

* NASA-AMMOS#369 Refresh vector layers, also some WEBSOCKET_ROOT_PATH (NASA-AMMOS#370) (NASA-AMMOS#371)

* NASA-AMMOS#368 Websockets use ROOT_PATH

* NASA-AMMOS#368 Fix configure websocket

* Fix bad Configure/websockets json writing

* Fix time memory leak from improper cleanup of tooltips and slider

* chore(config): Inline import from same namespace (NASA-AMMOS#375)

* NASA-AMMOS#378 LegendTool as Popup (NASA-AMMOS#379)

* NASA-AMMOS#378 Separate legend tool

* NASA-AMMOS#378 Legend formatting, reacts to layer toggles

* NASA-AMMOS#380 DrawTool - Fix error saving templateless features (NASA-AMMOS#381)

* Reset stroke styles too

* fix(imports): destructure modules (NASA-AMMOS#384)

* chore(naming): use standardized name (NASA-AMMOS#385)

* Add event listener for toggleSeparatedTool in MMGIS API (NASA-AMMOS#388)

* Prioritize Map splitscreen size when resizing

* NASA-AMMOS#372 calls to updateVectorLayer and appendLineString cause selected feature to be deselected when using info tool (NASA-AMMOS#389)

* NASA-AMMOS#372 Reselect feature on updateVectorLayer and appendLineString

* NASA-AMMOS#372 Non-async updateVectorLayer, fix Pairings update

* Remove description transition

* Persist active feature on appendLineString

* NASA-AMMOS#390 InfoTool - Clicks Intersect Polygons (NASA-AMMOS#391)

* NASA-AMMOS#387 DrawTool - Group Editing (NASA-AMMOS#392)

* NASA-AMMOS#387 DrawTool - Group edit files Part 1

* NASA-AMMOS#387 DrawTool - Group edit files Part 2

* DrawTool / Group Editing - Let other users save changes to features

* Added an option to the LegendTool to automatically display on start

* LegendTool needs to have hasVars set to true for the last commit

* Added max-width to legend to prevent long text from filling screen

* Added a .nvmrc file with node version

* Added ellipsis and title for overflow legend text

* NASA-AMMOS#386 Local Login Issue (NASA-AMMOS#396)

* NASA-AMMOS#386 Add setLoginToken to mmgisAPI

* NASA-AMMOS#386 Fix variable path

* NASA-AMMOS#386 SKIP_CLIENT_INITIAL_LOGIN env + mmgisAPI.initialLogin

* NASA-AMMOS#383 Support raster option on gdal2tiles_3.5.2/gdal2customtiles (NASA-AMMOS#397)

* NASA-AMMOS#383 gdal2tiles_3.5.2_v2 for raster support

* NASA-AMMOS#383 Cleanup gdal2tiles scripts and improve documentation

* NASA-AMMOS#383 gdal2customtiles extentworld working, overview tiles not working

* NASA-AMMOS#383 Fix gdal2customtiles rasters with different pixel scales

* gdal2customtiles - fix width calc, still slight offset

* gdal2customtiles raster - fix rounding issues

* Fix mmgisAPI featuresContained when a failed to load layer = null

* NASA-AMMOS#399 Crashes if Layers are valid JSON but not valid GeoJSON (NASA-AMMOS#400)

* NASA-AMMOS#399 Add geojson validater to map

* NASA-AMMOS#399 allow overloaded coordinates in geojson for extended geojson

* NASA-AMMOS#401 Extend CSSO timeout check to main client (NASA-AMMOS#402)

* NASA-AMMOS#401 Main site timeout notification part 1

* NASA-AMMOS#401 Main site timeout notification part 2

* NASA-AMMOS#401 Main site timeout notification - warn at 20 min

* NASA-AMMOS#403 rightClickMenuActions - Polygons and WKT (NASA-AMMOS#404)

* NASA-AMMOS#403 - Bugfixes and rightclick finds features

* NASA-AMMOS#403 ContextMenu, Actions on features, WKT link populate

* NASA-AMMOS#405 DrawTool - Template - Incrementer - Move to backend (NASA-AMMOS#406)

* Mini fix to allow [] as empty geojson layer data

* Fix DrawTool Incrementer self collision bug

* Convert layer data [<FeatureCollection>] to geojson

* NASA-AMMOS#407 Click intersects on Query and Draw layers (NASA-AMMOS#408)

* NASA-AMMOS#407 Include Query layers in click intersections

* NASA-AMMOS#407 Support intersects on DrawTool layers too

* Allow the legend tool to be right justified on the screen

* NASA-AMMOS#409 Added example config in description for LegendTool

* NASA-AMMOS#410 Draw Tool - Time Integration (NASA-AMMOS#411)

* ts-410 DrawTool - Temporal part 1

* NASA-AMMOS#410 DrawlTool - Temporal Integration

* NASA-AMMOS#410 Clearer DrawTool Template Date Start/End Icons

* NASA-AMMOS#412 Add Configuration Option to set TimeUI Extent (NASA-AMMOS#413)

* NASA-AMMOS#414 IdentifierTool works again with human layer names (NASA-AMMOS#415)

* NASA-AMMOS#422 Removed event blocking popup functions (NASA-AMMOS#423)

* Bump to 2.9.0

---------

Co-authored-by: ac-61 <[email protected]>
Co-authored-by: Joe Roberts <[email protected]>
Co-authored-by: Even Stensberg <[email protected]>
@andresinho20049
Copy link
Author

Pull request

I'm participating in the space apps challenge and I've been studying a lot about the EMIT challenge.

/change

@tariqksoliman
Copy link
Member

Hi @andresinho20049 and thanks for the PR!

A couple of things:

  • Please PR into the development branch. master is solely for the latest release.
    • (I agree there should be a contributing guide that says this.)
  • Everything in the /Database folder is legacy, unused and probably should be deleted.

@@ -1,4 +1,4 @@
FROM node:16
FROM node:16.13.2@sha256:7c49a64aba86dd483aa874bc0230c07f282e20741a7c66e426970ecafc149a38 as base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably upgrade this to Node v20.7

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, noted. I set the version that was in the NVMRC file, I will update.

// // build will also call this.
// if (process.env.NODE_ENV === "development") {
// console.log(chalk.cyan("Updating Tools...\n"));
// updateTools();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in fact needed. MMGIS can link into sub-repos of private tools and this updateTools functions scans for them and plugs them in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I offer my sincerest apologies for the error that occurred in my recent upload. My intention was to upload changes to my fork specifically, but by mistake, I uploaded them to the main repository instead. These changes were designed to simplify the process of running the project in development mode on my personal device, as I am not currently part of the NASA team. Regrettably, I also submitted a pull request to the master branch instead of creating a new branch named "spaceapps."

Upon reflection, I now understand that I should have exercised greater caution with respect to the timing of my pull request. I had previously created a new branch and made the necessary alterations in separate commits. However, during the pull request process, I became confused and made an error. I am deeply sorry for any inconvenience or confusion my actions may have caused.

I assure you that this was an unfortunate mistake, and I am committed to ensuring that it will not occur in the future. Once again, I apologize for any inconvenience caused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries whatsoever! This is what PRs are for too.

res.redirect(`http://localhost:${port + 1}`);
});
} else {
// app.get("/", ensureUser(), (req, res) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this DEV vs PROD distinction is breaking hot-reloading in DEV (because PROD is solely relying on the /build folder and scripts)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was not supposed to be in the pull, I modified it to run locally

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also detail the steps you've been taking to run this locally? We are interested in simplifying the initial installation and supporting a variety setups. Often we develop simply with npm start and only use Docker for final production images if the customer wishes to go that route.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the dockerfile, each time the FROM statement is included, a new layer of the image is created, so I divide the construction of the docker image with multi-stage.

Normally

  • the bases
  • as builder
  • as develop
  • and final version

The big trick when running in development is to configure the volume, basically building a volume pointing to the src and in the script instead of starting with node, using nodemon for example, in java using Dev tools dependency, then it is possible to run in development.

And in the final version, I only copy the build / out file and only the run time in this image, unlike the dev one, here the intention is to leave just one image with instructions to run the package and as light as possible.


My sample of Dockerfile

########### Stage BUILD ###########
FROM maven:3.6.3-jdk-8-slim as builder

# Define Workdir
WORKDIR /opt/app
#Copy pom.xml to container
COPY pom.xml ./

RUN mvn dependency:go-offline

COPY ./src ./src
RUN mvn clean
RUN mvn install package

########### Stage RUN ###########
FROM eclipse-temurin:8-jre-alpine@sha256:f6485e494f9927cb6a51e23134b3556c62c32c3df20fc4317f7f493343726977 as runner
SHELL ["/bin/sh", "-c"]

RUN mkdir -p /etc/skel/

RUN echo 'history -c \
/bin/rm -f /opt/remote/.mysql_history \
/bin/rm -f /opt/remote/.history \
/bin/rm -f /opt/remote/.bash_history' >> /etc/skel/.logout

RUN echo 'set autologout = 30 \
set prompt = "$ " \
set history = 0 \
set ignoreeof' >> /etc/skel/.cshrc

RUN cp /etc/skel/.cshrc /etc/skel/.profile

# dumb-init occupies PID 1 and takes care of all the responsibilities.
RUN apk add dumb-init

# Define Workdir
WORKDIR /opt/app

# Add user javauser based minumum privileges
RUN addgroup -S -g 1000 javagroup && \
    adduser -S -s /bin/false -G javagroup -u 999 javauser

RUN echo "javauser:secretPass" | chpasswd

# Copy target from build stage
COPY --from=builder /opt/app/target/AuthService.war ./

RUN chmod 0 /home \
    && chmod 0 /var \
    && chmod 0 /usr \
    && chmod 0 /dev \
    && chmod 0 /mnt \
    && chmod go-rw /etc \
    && chmod 0 /etc/ssl \
    && chmod 0 /etc/skel \
    && chmod a+rwx /usr/bin/dumb-init

RUN chown -R javauser:javagroup /opt/app
USER javauser

ENTRYPOINT ["dumb-init", "java", "-jar", "AuthService.war"] # I will create an entrypoint

In the case of this image presented above, I run it through compose pointing the target to the builder version and I configure a volume in the ./src folder

# Bundle app source
COPY . .

# build
RUN npm run build

EXPOSE 8888
CMD [ "npm", "run", "start:prod" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's starting the application if this is removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the entrypoint call in compose, because in this case I left the environment thought of as a development environment

db:
image: postgis/postgis:10-2.5-alpine
env_file: .env
ports:
- 5432:5432
- 5433:5432
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind port 5433?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I already had another Postgres database running and that's why I changed it to avoid local conflicts.

restart: on-failure
volumes:
- mmgis-db:/var/lib/postgresql/data
- ./Database:/usr/src/app/Database
- ./Database/PgSQL_queries/mmgisDB_queries.sql:/docker-entrypoint-initdb.d/mmgisDB_queries.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, the MMGIS ./Database directory is obsolete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! But it was good because I was able to run EMIT locally and load the prod configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants