Skip to content

Commit

Permalink
Merge pull request #24 from racemap/better-status-report
Browse files Browse the repository at this point in the history
Better status report
  • Loading branch information
karlTGA authored Aug 15, 2023
2 parents 555f6b3 + 59b0061 commit 8932d58
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 90 deletions.
87 changes: 0 additions & 87 deletions .circleci/config.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/buildImage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build Image

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'

jobs:
image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: racemap/elevation-service

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Build
uses: docker/build-push-action@v4
with:
push: false
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Test S3
run: |
docker run \
--rm \
-d \
-eTILE_SET_PATH=s3:// \
-p3000:3000 \
--name elevation \
"racemap/elevation-service:${{ steps.meta.outputs.version }}"
sleep 5
RESULT=$(curl \
-d '[[51.3, 13.4], [51.4, 13.3]]' \
-XPOST \
-H 'Content-Type: application/json' \
http://localhost:3000)
[ "$RESULT" = "[101,100]" ]
RESULT=$(curl http://localhost:3000/\?lat\=51.3\&lng\=13.4)
[ "$RESULT" = "101" ]
docker stop elevation
- name: Test Local
run: |
mkdir -p data/N51
wget \
https://elevation-tiles-prod.s3.amazonaws.com/skadi/N51/N51E013.hgt.gz \
-O data/N51/N51E013.hgt.gz
docker run \
--rm \
-d \
-p3000:3000 \
--name elevation \
-v$(pwd)/data:/app/data \
"racemap/elevation-service:${{ steps.meta.outputs.version }}"
sleep 5
RESULT=$(curl \
-d '[[51.3, 13.4], [51.4, 13.3]]' \
-XPOST \
-H 'Content-Type: application/json' \
http://localhost:3000)
[ "$RESULT" = "[101,100]" ]
RESULT=$(curl http://localhost:3000/\?lat\=51.3\&lng\=13.4)
[ "$RESULT" = "101" ]
docker stop elevation
- name: Push
uses: docker/build-push-action@v4
if: github.event_name != 'pull_request'
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM node:14

COPY . /app
WORKDIR /app
RUN yarn install
RUN yarn install --frozen-lockfile && yarn test

ENV TILE_SET_CACHE 128
ENV TILE_SET_PATH /app/data
Expand All @@ -12,4 +12,4 @@ EXPOSE 3000

HEALTHCHECK CMD curl --fail http://localhost:3000/status || exit 1

CMD ["yarn", "run", "start"]
CMD ["yarn", "start"]
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ async function handleGET(req, res) {
}

async function handleGETStatus(req, res) {
return send(res, 200, 'Ok');
try {
// try to receive a test value
await tiles.getElevation([0, 0]);
return send(res, 200, 'Ok');
} catch (error) {
console.error('Status Check Failed!');
console.error(error);
return send(res, 500, 'Error');
}
}

async function handler(req, res) {
Expand Down

0 comments on commit 8932d58

Please sign in to comment.