diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..719acf3e7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +build +gradle +out +.gradle +.idea +.DS_Store \ No newline at end of file diff --git a/.gitignore b/.gitignore index 042004e89..c3d4df138 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ gradlew # IntelliJ IDEA .idea/ +# Compose Volumes +compose + logs project/project project/target diff --git a/Dockerfile b/Dockerfile index b4895e989..f9396290e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,39 @@ -# Build with: -# docker build . --build-arg r5version=$(gradle -q printVersion | head -n1) -# or -# docker build . --build-arg r5version=$(cat build/version.txt) -# We could instead run the Gradle build and/or fetch version information -# using run actions within the Dockerfile -FROM openjdk:11 -ARG r5version -ENV R5_VERSION=$r5version -ENV JVM_HEAP_GB=2 -WORKDIR /r5 -COPY build/libs/r5-${R5_VERSION}-all.jar . -# Use a configuration that connects to the database on another host (container) +FROM openjdk:21-slim-bullseye AS base + + +FROM base AS builder +WORKDIR /app + +# Install unzip +RUN apt-get update && apt-get install -y unzip git + +# Install Gradle 8.5 +ENV GRADLE_VERSION=8.5 +ADD https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip /tmp/gradle.zip +RUN unzip -d /opt/gradle /tmp/gradle.zip && \ + ln -s /opt/gradle/gradle-${GRADLE_VERSION} /opt/gradle/latest && \ + rm /tmp/gradle.zip + +# Add Gradle to PATH +ENV PATH="/opt/gradle/latest/bin:${PATH}" + +# Copy the project files +COPY . . + +# Run gradle build with more verbose output +RUN gradle build + +# Run gradle shadowJar +RUN gradle shadowJar + +# Move the built jar, which is named by git describe, to r5.jar +RUN mv build/libs/r5-*-all.jar r5.jar + + +FROM base AS runner +WORKDIR /app +COPY --from=builder /app/r5.jar r5.jar COPY analysis.properties.docker analysis.properties + EXPOSE 7070 -CMD java -Xmx${JVM_HEAP_GB}g -cp r5-${R5_VERSION}-all.jar com.conveyal.analysis.BackendMain +CMD java -Xmx16g -cp r5.jar com.conveyal.analysis.BackendMain \ No newline at end of file diff --git a/analysis.properties.docker b/analysis.properties.docker index f1f8c79d6..ffcce3217 100644 --- a/analysis.properties.docker +++ b/analysis.properties.docker @@ -1,17 +1,44 @@ -# When running in docker, we reference services running on other containers -# The database is given the hostname mongo by the docker-compose links section +# This file contains the configuration options for Conveyal Analysis Backend + +immediate-shutdown=false + +# The host and port of the Mongo server. database-uri=mongodb://mongo:27017 + +# The name of the database in the Mongo instance. database-name=analysis -frontend-url=https://ui:3000 -bundle-bucket=analysis-local-bundles -grid-bucket=analysis-local-grids -results-bucket=analysis-local-results -resources-bucket=analysis-local-resources + +# The S3 bucket where we can find tiles of the entire US census, built with Conveyal seamless-census. seamless-census-bucket=lodes-data-2014 seamless-census-region=us-east-1 + +# When offline is true, authentication and other services are not used. +# This is only partially true - regional results will still be saved on S3. offline=true + +# The AWS region in which the server is running, and in which you want to run worker machines. +aws-region=eu-west-1 + +# The port on which the server will listen for connections from clients and workers. server-port=7070 -local-cache=cache + +# The origin where the frontend is hosted. When running locally, this will generally be http://localhost:3000. +# It should be relatively safe to set this to * (allowing requests from anywhere) when authentication is enabled. +# This increases attack surface though, so it is preferable to set this to the specific origin where the UI is hosted. +access-control-allow-origin=http://localhost:3000 + +# A temporary location to store scratch files. The path can be absolute or relative. +# This allows you to locate temporary storage on an extra drive in case your main drive does not have enough space. +local-cache=/app/files + +# Java threads for lighter async operations light-threads=3 + +# Java threads for heavy operations heavy-threads=3 + +# Max number of instances to start. +# If there are more than this number running more instances will not be started. +# This limit doesn't work very well because if you've manually started 200 workers on one graph, +# the broker then won't start more workers for a completely different job. max-workers=8 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 3e2da62ca..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Usage: -# docker-compose build --build-arg r5version=$(cat build/version.txt) -# docker-compose up -version: '3' -services: - r5: - container_name: r5 - build: . - # image: ghcr.io/conveyal/r5:latest - depends_on: - - mongo - links: - - mongo - ports: - - "7070:7070" - # TODO volumes for backend cache directory - ui: - container_name: ui - depends_on: - - mongo - # build: ../analysis-ui - # image: ghcr.io/conveyal/analysis-ui:latest - image: 037a38bb2cdf - ports: - - "3000:3000" - links: - - r5 - - mongo - # Map in a config file with mapbox keys, telling the UI to contact host (container) r5 - volumes: - - ./ui-env:/ui/.env.local:ro - mongo: - container_name: mongo - image: mongo - restart: always - volumes: - - mongo-volume:/data/db:rw - ports: - - "27017:27017" - -volumes: - mongo-volume: