-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fa0b7c
commit e99e5d5
Showing
5 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
Dockerfile* | ||
docker-compose* | ||
.git | ||
.gitignore | ||
README.md | ||
.vscode | ||
target | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Docker Build, Test & Push | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build and Test | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
tags: web-backend:latest | ||
push: false | ||
|
||
- name: Login to Google Artifact Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: us-east5-docker.pkg.dev | ||
username: _json_key | ||
password: ${{ secrets.GAR_KEY }} | ||
|
||
- name: Push to Google Artifact Registry | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
tags: us-east5-docker.pkg.dev/wheelshare-webapp/wheelshare/web-backend:latest | ||
push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ----- Build Stage ----- | ||
FROM maven:3.9.4-eclipse-temurin-17-alpine AS builder | ||
|
||
WORKDIR /app | ||
|
||
# Copy the pom.xml file | ||
COPY pom.xml . | ||
|
||
# Download dependencies | ||
RUN mvn dependency:go-offline -B | ||
|
||
# Copy the source code | ||
COPY src src | ||
|
||
# Build the project | ||
RUN mvn package | ||
|
||
# ----- Run Stage ----- | ||
FROM openjdk:17-jdk-alpine AS runtime | ||
|
||
WORKDIR /app | ||
|
||
# Copy the jar file from the builder stage | ||
COPY --from=builder /app/target/my-path-back-end-*.jar app.jar | ||
|
||
# Copy the map download script | ||
COPY downloadMap.sh . | ||
|
||
# Make map download script executable | ||
RUN chmod +x downloadMap.sh | ||
|
||
# Create a cron job to run the map download script every 5 minutes | ||
RUN echo "*/5 * * * * /app/downloadMap.sh" > /etc/crontabs/root | ||
|
||
# Expose API port | ||
EXPOSE 8081 | ||
|
||
# Run the jar file | ||
CMD ["/bin/sh", "-c", "/app/downloadMap.sh && crond && exec java -jar app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
#This script downloads the OSM data by hitting the Overpass API | ||
|
||
#Set default bounding box | ||
minLon=-84.7872 | ||
maxLon=-84.6941 | ||
minLat=39.4929 | ||
maxLat=39.5209 | ||
|
||
echo "Downloading OSM data for bounding box: $minLon,$minLat,$maxLon,$maxLat" | ||
|
||
wget -O ./mapData.json "https://overpass-api.de/api/interpreter?data=[out:json];(node($minLat,$minLon,$maxLat,$maxLon);<;);out%20meta;" && echo "Last Success Downloaded at $(date)" > "./map-download-history.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters