Skip to content

Commit

Permalink
Merge pull request #192 from entur/docker-examples
Browse files Browse the repository at this point in the history
Add docker-compose example
  • Loading branch information
testower authored Aug 8, 2023
2 parents fba9043 + bfba83c commit 0e892b6
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docker-compose/Dockerfile.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM eclipse-temurin:17.0.6_10-jdk-alpine

RUN apk update && apk upgrade && apk add --no-cache \
tini

RUN addgroup appuser && adduser --disabled-password appuser --ingroup appuser
USER appuser

WORKDIR /home/appuser

RUN chown -R appuser:appuser /home/appuser
USER appuser

COPY target/lamassu-0.0.1-SNAPSHOT.jar lamassu.jar

CMD [ "/sbin/tini", "--", "java", "-jar", "lamassu.jar" ]
23 changes: 23 additions & 0 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Docker examples for lamassu

This directory contains docker-compose examples for lamassu.

## Usage

Make sure you have built lamassu (check for jar file in `..target/`).

Edit `application-config/feedproviders.yml` so that it contains at least one source feed.

The run docker-compose:

docker-compose -f docker-compose-simple.yml up

or

docker-compose -f docker-compose-advanced.yml up

The difference between simple and advanced is that simple runs a single instance of lamassu, whereas
advanced runs two instances, one which is responsible for fetching data from upstream sources and updating
caches (leader), and one which responds to API requests. The second instance may be scaled horizontally, but
the leader can only have one instance, and must be scaled vertically if needed.

57 changes: 57 additions & 0 deletions docker-compose/application-config/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Spring Actuator
management.server.port=9001
management.endpoints.enabled-by-default=false
management.endpoint.info.enabled=true
management.endpoint.health.enabled=true
management.endpoint.health.group.readiness.include=readinessState
management.endpoint.prometheus.enabled=true
management.endpoints.web.exposure.include=info,health,prometheus
management.health.redis.enabled=true

# Logging
logging.level.no.entur.lamassu=DEBUG

# Redis
org.entur.lamassu.redis.master.host=redis
org.entur.lamassu.redis.master.port=6379
org.entur.lamassu.redis.slave.enabled=false
#org.entur.lamassu.redis.slave.host=
#org.entur.lamassu.redis.slave.port=

# graphql starter
graphiql.enabled=true
graphql.servlet.actuator-metrics=true
graphql.servlet.corsEnabled=false

# spring boot
# Enable response compression and http2
server.compression.enabled=true
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
server.compression.min-response-size=1024
server.http2.enabled=true
server.tomcat.keep-alive-timeout=120000

# Graceful shutdown of server
server.shutdown=graceful

# Application configuration

## Where to find configured feed providers
org.entur.lamassu.feedproviders=file:/etc/application-config/feedproviders.yml

## The target GBFS version (in output feeds)
org.entur.lamassu.targetGbfsVersion=2.3

## Base URL for API (needed for URL transformations)
org.entur.lamassu.baseUrl=http://localhost:8080

## Host / IP of internal load balancer for internal endpoints (Entur)
org.entur.lamassu.internalLoadBalancer=http://localhost:8080

org.entur.lamassu.serializationVersion=1

## Enable validation for all feeds
org.entur.lamassu.enableValidation=true

## Control filtering of virtual stations
org.entur.lamassu.excludeVirtualStations=false
2 changes: 2 additions & 0 deletions docker-compose/application-config/feedproviders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lamassu:
providers:
29 changes: 29 additions & 0 deletions docker-compose/docker-compose-advanced.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
redis:
image: "redis:alpine"
lamassu:
build:
context: ../
dockerfile: ./docker-compose/Dockerfile.example
ports:
- "8080:8080"
- "9001:9001"
environment:
JDK_JAVA_OPTIONS:
-Dspring.config.location=/etc/application-config/application.properties
volumes:
- ./application-config:/etc/application-config
lamassu-leader:
build:
context: ../
dockerfile: ./docker-compose/Dockerfile.example
ports:
- "8081:8080"
- "9002:9001"
environment:
JDK_JAVA_OPTIONS:
-Dspring.config.location=/etc/application-config/application.properties
-Dspring.profiles.active=leader
-Dorg.entur.lamassu.adminPassword=secret
volumes:
- ./application-config:/etc/application-config
17 changes: 17 additions & 0 deletions docker-compose/docker-compose-simple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
redis:
image: "redis:alpine"
lamassu:
build:
context: ../
dockerfile: ./docker-compose/Dockerfile.example
ports:
- "8080:8080"
- "9001:9001"
environment:
JDK_JAVA_OPTIONS:
-Dspring.config.location=/etc/application-config/application.properties
-Dspring.profiles.active=leader
-Dorg.entur.lamassu.adminPassword=secret
volumes:
- ./application-config:/etc/application-config

0 comments on commit 0e892b6

Please sign in to comment.