Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into station-bug-fix-2
Browse files Browse the repository at this point in the history
  • Loading branch information
david-i-berry committed Sep 19, 2023
2 parents 9f87270 + bac61e9 commit 40774d6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/basic_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: docker build -t wis2box-webapp ./webapp/

- name: Start Docker Compose services
run: docker-compose -f test/docker-compose.yml up -d
run: docker-compose -f test/docker-compose.yml up -d --build

- name: Wait for service to start
run: sleep 45
Expand Down
4 changes: 2 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version: '3.3'
services:
wis2box-webapp-test:
container_name: wis2box-webapp-test
image: wis2box-webapp:latest
build: ../webapp
environment:
- WIS2BOX_API_URL=http://localhost/oapi
- WIS2BOX_URL=http://localhost
- VITE_TEST_MODE=true
ports:
- 8080:4173 # port mapping for webapp
6 changes: 6 additions & 0 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ EXPOSE 4173
# Copy the entrypoint script into /app and make it executable
RUN chmod +x /wis2box-webapp/docker-entrypoint.sh

COPY healthcheck.sh /wis2box-webapp/healthcheck.sh

RUN chmod +x /wis2box-webapp/healthcheck.sh

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD /wis2box-webapp/healthcheck.sh

# Set the entrypoint
ENTRYPOINT ["sh", "/wis2box-webapp/docker-entrypoint.sh"]
35 changes: 31 additions & 4 deletions webapp/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#!/bin/bash

# Set VITE_API_URL to the value of WIS2BOX_API_URL
echo "set VITE_API_URL to the value of WIS2BOX_API_URL in .env"
echo "VITE_API_URL=$WIS2BOX_API_URL"
export VITE_API_URL=$WIS2BOX_API_URL
# check WIS2BOX_URL is set
if [ -z "$WIS2BOX_URL" ]; then
echo "WIS2BOX_URL is not set"
exit 1
fi

# Set VITE_URL to the value of WIS2BOX_URL/oapi
echo "VITE_API_URL=$WIS2BOX_URL/oapi"
export VITE_API_URL=$WIS2BOX_URL/oapi

# Set VITE_BASE_URL to the value of WIS2BOX_URL/wis2box-webapp
echo "VITE_BASE_URL=$WIS2BOX_URL/wis2box-webapp"
export VITE_BASE_URL=$WIS2BOX_URL/wis2box-webapp

# Set VITE_BASEMAP_URL to WIS2BOX_BASEMAP_URL if it is set
if [ -z "$WIS2BOX_BASEMAP_URL" ]; then
echo "WIS2BOX_BASEMAP_URL is not set use default basemap"
VITE_BASEMAP_URL="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
else
export VITE_BASEMAP_URL=$WIS2BOX_BASEMAP_URL
fi
echo "VITE_BASEMAP_URL=$VITE_BASEMAP_URL"

# repeat for VITE_BASEMAP_ATTRIBUTION
if [ -z "$WIS2BOX_BASEMAP_ATTRIBUTION" ]; then
echo "WIS2BOX_BASEMAP_ATTRIBUTION is not set use default basemap attribution"
VITE_BASEMAP_ATTRIBUTION="<a href="https://osm.org/copyright">OpenStreetMap</a> contributors"
else
export VITE_BASEMAP_ATTRIBUTION=$WIS2BOX_BASEMAP_ATTRIBUTION
fi
echo "VITE_BASEMAP_ATTRIBUTION=$VITE_BASEMAP_ATTRIBUTION"

npm run build
npm run preview
9 changes: 9 additions & 0 deletions webapp/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# Custom health check script

# Check if npm run preview is running
if ps aux | grep 'npm run preview' | grep -v grep; then
exit 0 # Process found, container is healthy
else
exit 1 # Process not found, container is not healthy
fi

0 comments on commit 40774d6

Please sign in to comment.