Skip to content

Commit

Permalink
Merge pull request #2 from rtuszik/docker_image
Browse files Browse the repository at this point in the history
fixed, dockerfile, update docker image
  • Loading branch information
rtuszik authored Oct 1, 2024
2 parents e26c5c9 + 8d67c04 commit 8226dc6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

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

Expand Down
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
FROM openjdk:21-jdk
FROM adoptopenjdk/openjdk11

# Set the working directory
WORKDIR /app

# Define an argument to accept the Photon version
# Install necessary tools
RUN apt-get update && apt-get install -y wget pbzip2 curl

# Define build argument for Photon version
ARG PHOTON_VERSION

# Download the Photon JAR file for the specified version
RUN curl -L -o photon.jar https://github.com/komoot/photon/releases/download/${PHOTON_VERSION}/photon-${PHOTON_VERSION}.jar
# Download the specified Photon release
RUN wget https://github.com/komoot/photon/releases/download/${PHOTON_VERSION}/photon-${PHOTON_VERSION}.jar -O photon.jar

# Copy the startup script
COPY start-photon.sh /app/start-photon.sh
RUN chmod +x /app/start-photon.sh

# Expose the default Photon port
EXPOSE 2322

# Run the Photon server
CMD ["java", "-jar", "photon.jar"]
# Set the command to run the startup script
CMD ["/app/start-photon.sh"]
25 changes: 25 additions & 0 deletions start-photon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

DATA_DIR="/app/photon_data"
INDEX_URL="https://download1.graphhopper.com/public/photon-db-latest.tar.bz2"

# Function to download and extract the index
download_and_extract_index() {
echo "Downloading and extracting the Photon index..."
mkdir -p "$DATA_DIR"
wget -O - "$INDEX_URL" | pbzip2 -cd | tar x -C "$DATA_DIR"
echo "Index downloaded and extracted successfully."
}

# Check if the index already exists
if [ ! -d "$DATA_DIR" ] || [ -z "$(ls -A "$DATA_DIR")" ]; then
download_and_extract_index
else
echo "Photon index already exists. Skipping download."
fi

# Start Photon
echo "Starting Photon..."
exec java -jar photon.jar -data-dir "$DATA_DIR"

0 comments on commit 8226dc6

Please sign in to comment.