Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '25'
distribution: corretto
cache: maven

Expand Down
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
# Run: docker run --name moresleep-container -p 5000:5000 moresleep-app:latest
# Check localhost:5000 and you should get a homepage
# Stage 1: Build the application
FROM maven:3.9.11-eclipse-temurin-21 AS build
FROM maven:3.9.12-eclipse-temurin-25 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -Dmaven.test.skip=true

# Stage 2: Create the final runtime image
FROM eclipse-temurin:21-jre-jammy AS final
FROM eclipse-temurin:25-jre-jammy AS final

# Install SOPS
RUN curl -L -o /usr/local/bin/sops https://github.com/getsops/sops/releases/download/v3.10.2/sops-v3.10.2.linux.amd64 && \
chmod +x /usr/local/bin/sops

# Install unzip and curl
RUN apt-get update && \
# Install unzip and curl
RUN apt-get update -y && \
apt-get install -y curl unzip && \
rm -rf /var/lib/apt/lists/*

# Install SOPS
RUN curl -L -o /usr/local/bin/sops https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.linux.amd64 && \
chmod +x /usr/local/bin/sops

# Install AWS CLI v2
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip" && \
unzip /tmp/awscliv2.zip -d /tmp && \
/tmp/aws/install && \
rm -rf /tmp/aws /tmp/awscliv2.zip

WORKDIR /app
COPY --from=build /app/target/cake-redux-0.3-SNAPSHOT-jar-with-dependencies.jar app.jar
COPY --from=build /app/target/cake-redux-jar-with-dependencies.jar app.jar
COPY ./config/.enc.prod.env /app/.enc.env

# Remove AWS profile from SOPS config to use container's AWS credentials
RUN sed -i 's/sops_kms__list_0__map_aws_profile=javabin/sops_kms__list_0__map_aws_profile=/' /app/.enc.env

EXPOSE 8081
ENTRYPOINT ["sops", "exec-env", ".enc.env", "java -jar app.jar"]
ENTRYPOINT ["sops", "exec-env", ".enc.env", "java -jar app.jar"]
54 changes: 54 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: cake-lie

services:
db:
image: postgres:17.6-alpine
restart: unless-stopped
command: |
postgres
-c max_connections=200
-c shared_buffers=2GB
-c wal_level=minimal
-c fsync=off
-c synchronous_commit=off
-c full_page_writes=off
-c work_mem=16MB
-c max_wal_senders=0
-c wal_level=minimal
-c wal_writer_delay=5s
-c wal_buffers=32MB
-c maintenance_work_mem=128MB
-c max_wal_size=3GB
-c shared_preload_libraries=pg_stat_statements,auto_explain
-c auto_explain.log_min_duration=50ms
-c auto_explain.log_analyze=true
-c auto_explain.log_buffers=true
-c auto_explain.log_timing=true
volumes:
- pg-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: localdevuser
POSTGRES_PASSWORD: localdevuser
POSTGRES_DB: moresleeplocal
TZ: Europe/Oslo
healthcheck:
test: [ "CMD" , "/usr/local/bin/pg_isready", "-d", "moresleeplocal", "-U", "localdevuser", "-t", "3" ]
retries: 3
timeout: 1m
start_period: 15s

moresleep:
image: ghcr.io/javabin/moresleep:edge
ports:
- "8082:8082"
env_file:
- path: ./.env.moresleep
required: false
environment:
DBHOST: db
depends_on:
db:
condition: service_healthy

volumes:
pg-data: {}
29 changes: 29 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[tools]
java = "25"
maven = "latest"

[tasks.infrastructure]
run = [
"""
if ! netstat -an | grep -q '[.:]5432\\b'; then
echo "Starter Infrastrutur..."
docker compose up --wait
else
echo "Infrastruturen kjører allerede"
fi
""",
""
]

[tasks.infrastructure-destroy]
run = [
"docker compose down -v"
]

[tasks.start]
depends = ["infrastructure"]
env = { SLEEPINGPILL_BASE_LOCATION = "http://localhost:8082", NO_AUTH_MODE = "true", SERVER_PORT = "5000", CAKE_LOCATION = "localhost" }
run = [
"mvn clean package",
"java -jar -Xmx512m -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 target/cake-redux-jar-with-dependencies.jar env-only"
]
78 changes: 57 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.javazone</groupId>
<artifactId>cake-redux</artifactId>
Expand All @@ -10,9 +11,23 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<kotlin.version>1.8.0</kotlin.version>
<kotlin.version>2.3.0</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.19.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.5</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
Expand All @@ -23,51 +38,62 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.16.v20190411</version>
<version>12.1.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>9.4.16.v20190411</version>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>12.1.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>12.1.5</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
<version>3.11.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<artifactId>mockito-core</artifactId>
<version>5.19.0</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.jsonbuddy</groupId>
<artifactId>jsonbuddy</artifactId>
<version>0.8.0</version>
<version>0.18.1</version>
</dependency>


<dependency>
<groupId>com.sendgrid</groupId>
<artifactId>sendgrid-java</artifactId>
<version>4.1.0</version>
<version>4.10.3</version>
</dependency>

<dependency>
<groupId>org.logevents</groupId>
<artifactId>logevents</artifactId>
<version>0.1.38</version>
<version>0.5.9</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand All @@ -77,6 +103,7 @@
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
Expand All @@ -85,7 +112,9 @@
<executions>
<execution>
<id>compile</id>
<goals> <goal>compile</goal> </goals>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
Expand All @@ -95,7 +124,9 @@
</execution>
<execution>
<id>test-compile</id>
<goals> <goal>test-compile</goal> </goals>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
Expand All @@ -110,10 +141,9 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>11</target>
<source>11</source>
<release>25</release>
</configuration>
<version>3.10.1</version>
<version>3.14.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
Expand All @@ -128,12 +158,16 @@
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Expand All @@ -145,7 +179,9 @@
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/no/javazone/cake/redux/DataServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import org.jsonbuddy.parse.JsonParser;
import org.jsonbuddy.pojo.PojoMapper;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/no/javazone/cake/redux/EntranceServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import org.jsonbuddy.JsonObject;
import org.jsonbuddy.parse.JsonParser;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/no/javazone/cake/redux/OpenDataServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.jsonbuddy.JsonObject;
import org.jsonbuddy.parse.JsonParser;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/no/javazone/cake/redux/SecurityFilter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.javazone.cake.redux;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;

public class SecurityFilter implements Filter {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/no/javazone/cake/redux/SigninServlet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package no.javazone.cake.redux;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SigninServlet extends HttpServlet {
Expand Down
Loading