Skip to content

Commit 42e8f71

Browse files
authored
Merge pull request #37 from pddg/photon-1.0.0
photon 1.0.0
2 parents d57508a + a6eca74 commit 42e8f71

17 files changed

Lines changed: 83 additions & 80 deletions

File tree

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
PHOTON_VERSION=0.7.3
2-
PHOTON_SHA256SUM=108438cd5d9404b2f68ee780281fa985f3afba67cf277225d68d038a2a7e69d3
1+
PHOTON_VERSION=1.0.0
2+
PHOTON_SHA256SUM=b2eaad11add95aad149d1e72e67a4df5f6694e725ac5363793a912c5b3e3a7df
33
CONTAINER_REVISION=0

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM mirror.gcr.io/debian:stable-slim AS builder
33
ARG PHOTON_VERSION
44
ARG PHOTON_SHA256SUM
55

6-
ADD https://github.com/komoot/photon/releases/download/${PHOTON_VERSION}/photon-opensearch-${PHOTON_VERSION}.jar /photon/photon.jar
6+
ADD https://github.com/komoot/photon/releases/download/${PHOTON_VERSION}/photon-${PHOTON_VERSION}.jar /photon/photon.jar
77

88
RUN echo "${PHOTON_SHA256SUM} /photon/photon.jar" | sha256sum -c -
99

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ Configuration is done via environment variables. The following environment varia
101101

102102
| Environment Variable | Description | Default Value |
103103
|----------------------|-------------|---------------|
104-
| `PHOTON_AGENT_DATABASE_URL` | The URL of the Photon database. | `https://download1.graphhopper.com/public/experimental/` |
105-
| `PHOTON_AGENT_DATABASE_COUNTRY_CODE` | The country code for the Photon index data. The code can be found from [here](https://download1.graphhopper.com/public/experimental/extracts/by-country-code/). | `` (full index data) |
104+
| `PHOTON_AGENT_DATABASE_URL` | The URL of the Photon database. | `https://download1.graphhopper.com/public/photon-db-planet-1.0-latest.tar.bz2` |
106105
| `PHOTON_AGENT_UPDATE_STRATEGY` | The update strategy for the Photon index. Can be `sequential` or `parallel`. | `sequential` |
107106
| `PHOTON_AGENT_DOWNLOAD_SPEED_LIMIT` | The speed limit for downloading the Photon index data. e.g. `10MB` | (no limit) |
108107
| `PHOTON_AGENT_IO_SPEED_LIMIT` | The speed limit for storage I/O operations. e.g. `10MB` | (no limit) |

cmd/photon-agent/main.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var (
3131
logLevel string
3232
logFormat string
3333
databaseURL string
34-
databaseCountryCode string
34+
listenIP string
3535
updateStrategy string
3636
downloadSpeedLimitBytesPerSec string
3737
ioSpeedLimitBytesPerSec string
@@ -48,13 +48,13 @@ func main() {
4848
flag.BoolVar(&disableMetrics, "disable-metrics", false, "disable photon database metrics (/metrics only provide go runtime information)")
4949

5050
// Photon database source options
51-
flag.StringVar(&databaseURL, "database-url", getEnv("PHOTON_AGENT_DATABASE_URL", downloader.DefaultDatabaseURL), "URL of the Photon database to download")
52-
flag.StringVar(&databaseCountryCode, "database-country-code", getEnv("PHOTON_AGENT_DATABASE_COUNTRY_CODE", ""), "country code of the Photon database to download. If empty, download the full database")
51+
flag.StringVar(&databaseURL, "database-url", getEnv("PHOTON_AGENT_DATABASE_URL", photondata.DefaultDatabaseURL), "URL of the Photon database to download")
5352

5453
// Photon server options
5554
flag.StringVar(&photonJarPath, "photon-jar-path", getEnv("PHOTON_AGENT_PHOTON_JAR_PATH", "/photon/photon.jar"), "path to the Photon jar file")
5655
flag.StringVar(&photonDir, "photon-dir", getEnv("PHOTON_AGENT_PHOTON_DIR", "/photon"), "directory to store the Photon data")
5756
flag.StringVar(&updateStrategy, "update-strategy", getEnv("PHOTON_AGENT_UPDATE_STRATEGY", string(updater.DefaultUpdateStrategy)), "update strategy for the Photon database")
57+
flag.StringVar(&listenIP, "photon-listen-ip", getEnv("PHOTON_AGENT_PHOTON_LISTEN_IP", "127.0.0.1"), "IP address to listen on by photon")
5858

5959
// Speed limit options
6060
flag.StringVar(&downloadSpeedLimitBytesPerSec, "download-speed-limit", getEnv("PHOTON_AGENT_DOWNLOAD_SPEED_LIMIT", ""), "download speed limit in bytes per second (e.g. 10MB). default is unlimited")
@@ -101,14 +101,16 @@ func innerMain(ctx context.Context) error {
101101
}
102102
downloaderOptions = append(downloaderOptions, downloader.WithDownloadSpeedLimit(downloadSpeedLimit))
103103
}
104-
if databaseCountryCode != "" {
105-
archiveOptions = append(archiveOptions, photondata.WithCountryCode(databaseCountryCode))
106-
}
107104

108-
photonArchive := photondata.NewArchive(databaseURL, archiveOptions...)
105+
photonArchive, err := photondata.NewArchive(databaseURL, archiveOptions...)
106+
if err != nil {
107+
return fmt.Errorf("invalid archive: %w", err)
108+
}
109109
dl := downloader.New(httpClient, downloaderOptions...)
110110
ua := unarchiver.NewUnarchiver(unarchiverOptions...)
111-
photonServer := photon.NewPhotonServer(ctx, photonJarPath, photonDir)
111+
photonServer := photon.NewPhotonServer(ctx, photonJarPath, photonDir, photon.WithArgs(
112+
"-listen-ip", listenIP,
113+
))
112114
photonDataDir := filepath.Join(photonDir, "photon_data")
113115
migrator := photondata.NewMigrator(photonDataDir, httpClient)
114116
updater, err := updater.New(

cmd/photon-db-updater/main.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var (
2323
logLevel string
2424
logFormat string
2525
databaseURL string
26-
databaseCountryCode string
2726
archivePath string
2827
archiveDownloadPath string
2928
downloadOnly bool
@@ -39,8 +38,7 @@ func main() {
3938
flag.StringVar(&logLevel, "log-level", getEnv("PHOTON_AGENT_LOG_LEVEL", "info"), "log level")
4039
flag.StringVar(&logFormat, "log-format", getEnv("PHOTON_AGENT_LOG_FORMAT", "json"), "log format")
4140

42-
flag.StringVar(&databaseURL, "database-url", getEnv("PHOTON_AGENT_DATABASE_URL", downloader.DefaultDatabaseURL), "URL of the Photon database to download")
43-
flag.StringVar(&databaseCountryCode, "database-country-code", getEnv("PHOTON_AGENT_DATABASE_COUNTRY_CODE", ""), "country code of the Photon database to download. If empty, download the full database")
41+
flag.StringVar(&databaseURL, "database-url", getEnv("PHOTON_AGENT_DATABASE_URL", photondata.DefaultDatabaseURL), "URL of the Photon database to download")
4442

4543
flag.StringVar(&archivePath, "archive", getEnv("PHOTON_UPDATER_ARCHIVE", ""), "path to the local archive if you want to use it instead of downloading")
4644
flag.StringVar(&archiveDownloadPath, "download-to", getEnv("PHOTON_UPDATER_DOWNLOAD_TO", "/tmp/photon-db.tar.bz2"), "path to download the archive. Skip downloading if md5sum matches with the existing file")
@@ -79,7 +77,10 @@ func innerMain(ctx context.Context) error {
7977
if err != nil {
8078
return err
8179
}
82-
archive := photondata.NewArchive(databaseURL, archiveOptions...)
80+
archive, err := photondata.NewArchive(databaseURL, archiveOptions...)
81+
if err != nil {
82+
return fmt.Errorf("invalid archive: %w", err)
83+
}
8384
dl := downloader.New(httpClient, downloadOptions...)
8485
agentClient := photonagent.NewClient(httpClient, photonAgentURL)
8586

@@ -151,9 +152,6 @@ func initOptions(
151152
}
152153
downloadOptions = append(downloadOptions, downloader.WithDownloadSpeedLimit(float64(limitBytes)))
153154
}
154-
if databaseCountryCode != "" {
155-
archiveOptions = append(archiveOptions, photondata.WithCountryCode(databaseCountryCode))
156-
}
157155
if force {
158156
uploadOptions = append(uploadOptions, photonagent.WithForceUpload())
159157
}

compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ services:
88
- PHOTON_SHA256SUM=${PHOTON_SHA256SUM}
99
- GIT_SHA="dev"
1010
environment:
11-
# Small country code for testing
12-
- PHOTON_AGENT_DATABASE_COUNTRY_CODE=ad
11+
# Small country data for testing
12+
- PHOTON_AGENT_DATABASE_URL=https://download1.graphhopper.com/public/europe/andorra/photon-db-andorra-1.0-latest.tar.bz2
1313
restart: unless-stopped
1414
ports:
1515
- "8080:8080"

e2e/cluster_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e_test
22

33
import (
44
"fmt"
5+
"os"
56
"strings"
67
"testing"
78
"time"
@@ -13,6 +14,10 @@ func setup(t *testing.T, ns string) (string, string) {
1314
t.Helper()
1415
kubectl(t, "create", "ns", ns)
1516
t.Cleanup(func() {
17+
if os.Getenv("DEBUG") == "true" {
18+
t.Logf("skip deleting %q namespace since DEBUG=true", ns)
19+
return
20+
}
1621
kubectl(t, "delete", "ns", ns)
1722
})
1823

e2e/suite_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import (
44
"testing"
55
)
66

7+
const (
8+
testDataURL = "https://download1.graphhopper.com/public/europe/andorra/photon-db-andorra-1.0-latest.tar.bz2"
9+
)
10+
711
func Test_ServerSideDownload(t *testing.T) {
812
t.Parallel()
913
ns := "server-side-dl"
@@ -30,7 +34,7 @@ func Test_UploadFromClientSide(t *testing.T) {
3034
"/bin/photon-db-uploader",
3135
"-download-to", "/tmp/photon-db.tar.bz2",
3236
"-photon-agent-url", photonAgentUrl,
33-
"-database-country-code", "ad",
37+
"-database-url", testDataURL,
3438
)
3539

3640
// Verify
@@ -50,7 +54,7 @@ func Test_UploadUncompressedFromClientSide(t *testing.T) {
5054
"/bin/photon-db-uploader",
5155
"-download-to", "/tmp/client-uncompressed.tar.bz2",
5256
"-download-only",
53-
"-database-country-code", "ad",
57+
"-database-url", testDataURL,
5458
)
5559
bastionExec(t,
5660
"bzip2", "-d", "/tmp/client-uncompressed.tar.bz2",

examples/compose/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
## Steps to Deploy
1212

1313
> [!NOTE]
14-
> By default, the environment variable `PHOTON_AGENT_DATABASE_COUNTRY_CODE` is set, which limits the download to data for a few countries with smaller index sizes.
15-
> You can find country codes from [here](https://download1.graphhopper.com/public/experimental/extracts/by-country-code/).
14+
> By default, the environment variable `PHOTON_AGENT_DATABASE_URL` is set, which limits the download to data for a few countries with smaller index sizes.
1615
1716
> [!WARNING]
1817
> If you plan to use the full-size index, ensure that the volume has enough capacity to accommodate both the compressed archive and the extracted data. This requires at least 350 GiB of storage space.

examples/compose/compose.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ services:
33
image: ghcr.io/pddg/photon:latest
44
environment:
55
# Where to download the data from
6-
# Only supports OpenSearch compatible version.
7-
# Currently it is only tested with GraphHopper's experimental data.
8-
- PHOTON_AGENT_DATABASE_URL=https://download1.graphhopper.com/public/experimental/
9-
# Country code if you want to use only a specific country's data
10-
- PHOTON_AGENT_DATABASE_COUNTRY_CODE=ad
6+
# Only supports archives for photon 1.x or later.
7+
- PHOTON_AGENT_DATABASE_URL=https://download1.graphhopper.com/public/europe/andorra/photon-db-andorra-1.0-latest.tar.bz2
8+
# Photon listens only 127.0.0.1 by default.
9+
- PHOTON_AGENT_PHOTON_LISTEN_IP=0.0.0.0
1110
volumes:
1211
# Mount the photon data volume
1312
# /photon/photon_data is the default path for the index data

0 commit comments

Comments
 (0)