Skip to content

Commit

Permalink
Update maps server dockerfile (#29)
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei authored Oct 10, 2022
1 parent 56f7d41 commit 1aef822
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
3 changes: 2 additions & 1 deletion opensearch-maps-server/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
dist
dist
.idea
3 changes: 2 additions & 1 deletion opensearch-maps-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
dist
dist
.idea
50 changes: 32 additions & 18 deletions opensearch-maps-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0

########################### Stage 0 ########################
FROM amazonlinux:2 AS stage_0

WORKDIR /src

RUN yum install -y tar gzip unzip && yum clean all

RUN mkdir GeoJSONData && \
cd GeoJSONData && \
curl -SL -o geo-json-files.tar.gz https://maps.opensearch.org/offline/natural-earth-geo-json.tar.gz && \
tar -xzf geo-json-files.tar.gz --strip-components=1 && \
rm geo-json-files.tar.gz && pwd && ls

RUN mkdir oss_compliance && \
cd oss_compliance && \
curl -SL -o oss_compliance.zip https://aws-dlinfra-utilities.s3.amazonaws.com/oss_compliance.zip && \
unzip oss_compliance.zip && \
rm oss_compliance.zip

########################### Stage 1 ########################
FROM amazonlinux:2

WORKDIR /usr/src/app

RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash - && \
yum install -y nodejs wget tar gzip unzip python37 && \
yum clean all
COPY --from=stage_0 /src/GeoJSONData public/vectors/data
COPY --from=stage_0 /src/oss_compliance .

RUN pip3 install --no-cache --upgrade \
"requests>=2.18.4,<=2.22.0"
RUN curl -SL https://rpm.nodesource.com/setup_16.x | bash && \
yum install -y nodejs-16.17.1 python3 tar gzip && pip3 install requests==2.28.1 && yum clean all

COPY package*.json ./
RUN npm install
COPY . .

RUN mkdir -p public/vectors/data && \
cd public/vectors/data && \
wget -O vectors.tar.gz https://maps.opensearch.org/offline/natural-earth-geo-json.tar.gz && \
tar -xzf vectors.tar.gz --strip-components=1 && \
rm vectors.tar.gz

COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

EXPOSE 8080
RUN chmod +x oss_compliance/generate_oss_compliance.sh && \
oss_compliance/generate_oss_compliance.sh /usr/src/app python3 && \
cp oss_compliance/python_packages/piplicenses/PACKAGES_LICENSES_JSON.json PACKAGES_LICENSES_JSON.json && \
rm -rf oss_compliance* \

RUN wget -O oss_compliance.zip https://aws-dlinfra-utilities.s3.amazonaws.com/oss_compliance.zip \
&& unzip oss_compliance.zip \
&& chmod +x oss_compliance/generate_oss_compliance.sh \
&& oss_compliance/generate_oss_compliance.sh /usr/src/app python3 \
&& cp oss_compliance/python_packages/piplicenses/PACKAGES_LICENSES_JSON.json PACKAGES_LICENSES_JSON.json \
&& rm -rf oss_compliance*
EXPOSE 8080
6 changes: 3 additions & 3 deletions opensearch-maps-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Option1: Use the tiles set provided by OpenSearch maps service
docker volume create tiles-data
```
* Then download tiles set from OpenSearch maps service, we now have 0-8 and 0-10 planet tiles set available.
* https://maps.opensearch.org/offline/planet-osm-default-z0-z8-20220613.tar.gz
* https://maps.opensearch.org/offline/planet-osm-default-z0-z10-20220613.tar.gz
* https://maps.opensearch.org/offline/planet-osm-default-z0-z8.tar.gz
* https://maps.opensearch.org/offline/planet-osm-default-z0-z10.tar.gz

```
docker run \
-e DOWNLOAD_TILES=https://maps.opensearch.org/offline/planet-osm-default-z0-z8-20220613.tar.gz \
-e DOWNLOAD_TILES=https://maps.opensearch.org/offline/planet-osm-default-z0-z8.tar.gz \
-v tiles-data:/usr/src/app/public/tiles/data/ \
osm-server \
import
Expand Down
4 changes: 2 additions & 2 deletions opensearch-maps-server/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

set -e

Expand All @@ -21,7 +21,7 @@ if [ "${1}" = "import" ]; then
cd public/tiles/data
if [ -n "${DOWNLOAD_TILES:-}" ]; then
echo "INFO: Download Tiles images: $DOWNLOAD_TILES"
wget "$DOWNLOAD_TILES" -O tiles.tar.gz
curl -SL -o tiles.tar.gz "$DOWNLOAD_TILES"
tar -xzf tiles.tar.gz --strip-components=1
rm tiles.tar.gz
fi
Expand Down

0 comments on commit 1aef822

Please sign in to comment.