Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorgerhardt committed Nov 6, 2024
1 parent 9ba72c3 commit 340560d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
gradle
out
.gradle
.idea
.DS_Store
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ gradlew
# IntelliJ IDEA
.idea/

# Compose Volumes
compose

logs
project/project
project/target
Expand Down
51 changes: 37 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
43 changes: 35 additions & 8 deletions analysis.properties.docker
Original file line number Diff line number Diff line change
@@ -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
42 changes: 0 additions & 42 deletions docker-compose.yml

This file was deleted.

0 comments on commit 340560d

Please sign in to comment.