Skip to content

Commit

Permalink
Merge pull request #371 from EOEPCA/stac-browser-docker-build
Browse files Browse the repository at this point in the history
Stac browser docker build
  • Loading branch information
silvester-pari authored Nov 23, 2023
2 parents d3fdab3 + b43be90 commit 20201d7
Show file tree
Hide file tree
Showing 153 changed files with 76 additions and 423 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Created by .ignore support plugin (hsz.mobi)

#stac-browser
open-science-catalog-stac-browser
static/stac-browser/*
!static/stac-browser/stac-browser-config.js

### Node template
# Logs
/logs
Expand Down
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM node:16-alpine3.14
FROM node:16-alpine3.14 as browser
RUN apk --no-cache add git

RUN git clone https://github.com/EOEPCA/open-science-catalog-stac-browser.git
WORKDIR /open-science-catalog-stac-browser
RUN \
npm i \
&& npm run build



FROM node:16-alpine3.14
ENV NUXT_VERSION=2.15.8

WORKDIR /app

ADD . ./
COPY --from=browser /open-science-catalog-stac-browser/dist/ static/stac-browser/
COPY static/stac-browser/stac-browser-config.js static/stac-browser/config.js

RUN : \
&& npm install \
&& npm run build --standalone \
Expand All @@ -13,8 +26,8 @@ RUN : \
# && npm install "nuxt-start@${NUXT_VERSION}" \
&& npm cache clean –force \
&& :

RUN chmod +x ./docker-entrypoint.sh
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
EXPOSE 3000
ENTRYPOINT ["npx", "nuxt", "start"]
ENTRYPOINT ["/app/docker-entrypoint.sh"]
41 changes: 33 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,50 @@ These endpoints are primarily used within the application [central store](./stor

## Development Setup

### Install dependencies

```bash
# install dependencies
$ npm install
```

### Build and configure [Open Science Catalog STAC Browser](https://github.com/EOEPCA/open-science-catalog-stac-browser) locally

# serve with hot reload at localhost:3000
Find STAC Browser [runtime configuration](https://github.com/radiantearth/stac-browser/blob/v3.1.0-rc.1/docs/options.md) in
`static/stac-browser/config.js`

```bash
$ npm run build:browser
```

### Serve with hot reload at localhost:3000

```bash
$ npm run dev
```

### Build for production and launch server

# build for production and launch server
```bash
$ npm run build
$ npm run start
```

### Generate static project

# generate static project
```bash
$ npm run generate
```

#lint
$ npm run lint (linting only)
$ npm lintfix (lint and fix)
### Lint

#test
```bash
$ npm run lint #linting only
$ npm run lint:fix #lint and fix
```

### Test

```bash
$ npm run test
```

Expand Down
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sed -i "s| catalogUrl:.*| catalogUrl: '${STATIC_ENDPOINT}/catalog.json'|" static/stac-browser/config.js
npx nuxt start
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"build:browser": "git clone https://github.com/EOEPCA/open-science-catalog-stac-browser.git && cd open-science-catalog-stac-browser && npm i && npm run build && cp -r dist/* ../static/stac-browser/ && cd .. && cp -r static/stac-browser/stac-browser-config.js static/stac-browser/config.js && rm -rf open-science-catalog-stac-browser",
"start": "nuxt start",
"generate": "nuxt generate",
"lint": "eslint . --ext js,vue",
Expand Down
22 changes: 12 additions & 10 deletions pages/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ export default {
firstLoadDone: false,
}),
mounted() {
this.iframeSrc = `/stac-browser/?external=${this.prepareEndpoint(
this.$config.staticEndpoint
)}${this.$route.path}.json`;
this.iframeSrc = this.stacBrowserPath(this.$route.fullPath);
window.addEventListener("message", (evt) => {
if (evt.data && evt.data.navigate && this.firstLoadDone) {
const stringToReplace = `/external/${this.prepareEndpoint(
this.$config.staticEndpoint
)}`;
const parsedPath = evt.data.navigate
.replace(stringToReplace, "")
.replace(".json", "");
history.replaceState({}, null, parsedPath);
const innerPath = evt.data.navigate.replace(".json", "");
history.replaceState(
{},
null,
`${innerPath.length > 1 ? innerPath : "/catalog"}`
);
} else {
this.firstLoadDone = true;
}
Expand All @@ -38,6 +36,10 @@ export default {
prepareEndpoint(src) {
return src.replace("https://", "").replace("http://", "");
},
stacBrowserPath(path) {
let hashPath = path.length > 1 ? path + ".json" : "";
return `/stac-browser/#${hashPath}`;
},
},
};
</script>
Expand Down
1 change: 0 additions & 1 deletion static/stac-browser/css/1364.c8af9558.css

This file was deleted.

1 change: 0 additions & 1 deletion static/stac-browser/css/2418.9f5851a0.css

This file was deleted.

1 change: 0 additions & 1 deletion static/stac-browser/css/3206.0780c10b.css

This file was deleted.

1 change: 0 additions & 1 deletion static/stac-browser/css/3366.480cfd4a.css

This file was deleted.

1 change: 0 additions & 1 deletion static/stac-browser/css/3919.17cfc64f.css

This file was deleted.

Loading

0 comments on commit 20201d7

Please sign in to comment.