Skip to content

Commit

Permalink
#3 - using a (very) large write buffere fixed this
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Jul 1, 2024
1 parent 78744fb commit ce8dc77
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
13 changes: 8 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ ThisBuild / Test / javaOptions ++= Seq(
lazy val oni = project
.in(file("oni"))
.enablePlugins(
AutomateHeaderPlugin,
GitBranchPrompt,
GitVersioning,
AutomateHeaderPlugin,
DockerPlugin,
GitBranchPrompt,
GitVersioning,
JavaAppPackaging
)
.settings(
// Set version based on git tag. I use "0.0.0" format (no leading "v", which is the default)
// Use `show gitCurrentTags` in sbt to update/see the tags

dockerBaseImage := "eclipse-temurin:21",
dockerExposedPorts := Seq(8080),
dockerUpdateLatest := true,
git.gitTagToVersionNumber := { tag: String =>
if(tag matches "[0-9]+\\..*") Some(tag)
else None
Expand All @@ -73,7 +76,7 @@ lazy val oni = project
"""Copyright (c) Monterey Bay Aquarium Research Institute 2024
|
|oni code is non-public software. Unauthorized copying of this file,
|via any medium is strictly prohibited. Proprietary and confidential.
|via any medium is strictly prohibited. Proprietary and confidential.
|""".stripMargin
)
),
Expand Down
33 changes: 8 additions & 25 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
#!/usr/bin/env bash

echo "--- Building oni (reminder: run docker login first!!)"

BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
VCS_REF=`git tag | sort -V | tail -1`

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
echo "Working directory is $SCRIPT_DIR"
cd $SCRIPT_DIR

sbt stage
echo $SCRIPT_DIR

ARCH=$(uname -m)
if [[ $ARCH == 'arm64' ]]; then
sbt 'Docker / stage'
cd $SCRIPT_DIR/oni/target/docker/stage
VCS_REF=`git tag | sort -V | grep -E '^\d' | tail -1`
# https://betterprogramming.pub/how-to-actually-deploy-docker-images-built-on-a-m1-macs-with-apple-silicon-a35e39318e97
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t mbari/oni:${VCS_REF} \
-t mbari/oni:latest \
--push . && \
docker pull mbari/oni:${VCS_REF}
--push . \
&& docker pull mbari/oni:${VCS_REF}
else
docker build --build-arg BUILD_DATE=$BUILD_DATE \
--build-arg VCS_REF=$VCS_REF \
-t mbari/oni:${VCS_REF} \
-t mbari/oni:latest . && \
docker push mbari/oni
fi


# For M1 use:
# docker buildx build --load -t mbari/oni:latest .


# sbt stage && \
# docker build -t mbari/oni:latest
sbt 'Docker / publish'
fi
1 change: 1 addition & 0 deletions oni/src/main/scala/org/mbari/oni/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object Main:

WebServer
.builder()
.writeBufferSize(131072) // Big buffer to handle full kb tree
.routing(builder => builder.any(handler))
.port(port)
.build()
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/scala/org/mbari/oni/domain/Link.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ case class Link(linkName: String, toConcept: String, linkValue: String, id: Opti
l

object Link:
def from(link: ILink with IPersistentObject): Link =
def from(link: ILink & IPersistentObject): Link =
Link(link.getLinkName, link.getToConcept, link.getLinkValue, longConverter(link.getId))
4 changes: 3 additions & 1 deletion oni/src/main/scala/org/mbari/oni/services/LinkService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class LinkService(entityManagerFactory: EntityManagerFactory):
conceptRepo.findByName(conceptName).toScala match
case Some(concept) =>
repo.findAllApplicableToConcept(concept)
.asScala
.stream()
.map(Link.from)
.toList
.asScala
.toSeq
case None => throw ConceptNameNotFound(conceptName)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mbari.oni.domain

import org.mbari.oni.jpa.entities.{ConceptEntity, ConceptNameEntity}
import org.mbari.oni.etc.circe.CirceCodecs.{given, *}

class ConceptMetadataSuite extends munit.FunSuite {

Expand All @@ -16,10 +17,12 @@ class ConceptMetadataSuite extends munit.FunSuite {
assertEquals(metadata.rank, Some("rankLevelrankName"))
assertEquals(metadata.id, None)
assertEquals(metadata.aphiaId, None)
// println(metadata.stringify)

concept.setAphiaId(10)
val metadata2 = ConceptMetadata.from(concept)
assertEquals(metadata2.aphiaId, Some(10L))
// println(metadata2.stringify)

}

Expand Down

0 comments on commit ce8dc77

Please sign in to comment.