Umstellung auf podman in Arbeit

(cherry picked from commit 1a92c63ef6d60e9dcba513ebf60cbd9f18a142e8)
This commit is contained in:
Thomas Peetz
2026-01-28 11:18:41 +01:00
parent aff1720972
commit bb701a903d
21 changed files with 99 additions and 151 deletions
-38
View File
@@ -1,38 +0,0 @@
services:
postgres:
image: postgres
restart: unless-stopped
environment:
- POSTGRES_DB=kontor
- POSTGRES_USER=kontor
#- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
- POSTGRES_PASSWORD=kontor
healthcheck:
test: ["CMD-SHELL", "pg_isready -U kontor"]
interval: 1s
timeout: 5s
retries: 10
ports:
- 5432:5432
networks:
- database
volumes:
- postgres-data:/var/lib/postgresql/data:rw
secrets:
- db-password
adminer:
image: adminer
ports:
- 8090:8080
networks:
- database
- frontend
volumes:
postgres-data:
secrets:
db-password:
file: db-password.txt
networks:
database:
name: database
external: true
-57
View File
@@ -1,62 +1,5 @@
include:
- ./compose-postgres.yaml
services: services:
activemq:
image: apache/activemq-artemis:latest-alpine
restart: unless-stopped
ports:
- 61616:61616
- 8161:8161
- 5672:5672
networks:
- integration
- frontend
volumes:
- activemq-data:/var/lib/artemis-instance
kontor:
build:
context: ./kontor-spring
dockerfile: Dockerfile
tags:
- kontor:0.2.0-SNAPSHOT
image: kontor:0.2.0-SNAPSHOT
restart: unless-stopped
networks:
- database
- integration
- frontend
ports:
- 8100:8100
volumes:
- images-data:/data/images
depends_on:
postgres:
condition: service_healthy
kontor-api:
build:
context: ./kontor-api
dockerfile: Dockerfile
tags:
- kontor-api:0.2.0-SNAPSHOT
image: kontor-api:0.2.0-SNAPSHOT
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://kontor-api:8500/health"]
interval: 10s
timeout: 5s
retries: 3
networks:
- database
- integration
- frontend
ports:
- 8500:8500
volumes:
- images-data:/data/images
depends_on:
postgres:
condition: service_healthy
kontor-fiber: kontor-fiber:
build: build:
context: ./kontor-fiber context: ./kontor-fiber
@@ -20,25 +20,8 @@ RUN uv sync
# ------------------------------- Production Stage ------------------------------ ## # ------------------------------- Production Stage ------------------------------ ##
FROM python:3.13-slim-bookworm AS production FROM python:3.13-slim-bookworm AS production
# The following secrets are available during build time
#RUN --mount=type=secret,id=DB_PASSWORD \
# --mount=type=secret,id=DB_USER \
# --mount=type=secret,id=DB_NAME \
# --mount=type=secret,id=DB_HOST \
# --mount=type=secret,id=DB_PORT \
# DB_PASSWORD=/run/secrets/DB_PASSWORD \
# DB_USER=$(cat /run/secrets/DB_USER) \
# DB_NAME=$(cat /run/secrets/DB_NAME) \
# DB_HOST=$(cat /run/secrets/DB_HOST) \
# DB_PORT=$(cat /run/secrets/DB_PORT)
#RUN --mount=type=secret,id=secret-key,target=secrets.json
RUN apt-get update && apt-get install --no-install-recommends -y curl RUN apt-get update && apt-get install --no-install-recommends -y curl
RUN useradd --create-home appuser
USER appuser
WORKDIR /app WORKDIR /app
COPY /src src COPY /src src
@@ -48,8 +31,8 @@ COPY --from=builder /app/.venv .venv
ENV PATH="/app/.venv/bin:$PATH" ENV PATH="/app/.venv/bin:$PATH"
# Expose the specified port for FastAPI # Expose the specified port for FastAPI
EXPOSE $PORT EXPOSE 8200
# Start the application with Uvicorn in production mode, using environment variable references # Start the application with Uvicorn in production mode, using environment variable references
CMD ["uvicorn", "src.main:kontor", "--log-level", "info", "--host", "0.0.0.0" , "--port", "8500"] CMD ["uvicorn", "src.main:kontor", "--log-level", "info", "--host", "0.0.0.0" , "--port", "8200"]
+1 -1
View File
@@ -9,7 +9,7 @@ load_dotenv(dotenv_path=env_path)
class Settings: class Settings:
PROJECT_NAME: str = "Kontor" PROJECT_NAME: str = "Kontor"
PROJECT_VERSION: str = "0.2.0" PROJECT_VERSION: str = "0.3.0"
DB_USER: str = os.getenv("DB_USER", "kontor") DB_USER: str = os.getenv("DB_USER", "kontor")
DB_PASSWORD: str = os.getenv("DB_PASSWORD", "kontor") DB_PASSWORD: str = os.getenv("DB_PASSWORD", "kontor")
@@ -10,27 +10,23 @@ RUN gradle build --no-daemon
# ----------------------------------------------------------------------- # # ----------------------------------------------------------------------- #
#FROM alpine/java:21-jdk AS run #FROM alpine/java:21-jdk AS run
#RUN adduser --system appuser #COPY --from=builder /build/libs/kontor-quarkus-0.2.0-SNAPSHOT.jar app.jar
#COPY --from=builder --chown=appuser:appuser /build/libs/kontor-quarkus-0.2.0-SNAPSHOT.jar app.jar #EXPOSE 8300
#EXPOSE 8800
#USER appuser
#CMD ["java", "-jar", "-Dquarkus.http.host=0.0.0.0", "app.jar"] #CMD ["java", "-jar", "-Dquarkus.http.host=0.0.0.0", "app.jar"]
# ----------------------------------------------------------------------- # # ----------------------------------------------------------------------- #
FROM registry.access.redhat.com/ubi9/openjdk-21:1.23 FROM registry.access.redhat.com/ubi9/openjdk-21:1.23
ENV LANGUAGE='en_US:en' ENV LANGUAGE='de_DE:de'
# We make four distinct layers so if there are application changes the library layers can be re-used # We make four distinct layers so if there are application changes the library layers can be re-used
COPY --from=builder --chown=185 build/quarkus-app/lib/ /deployments/lib/ COPY --from=builder build/quarkus-app/lib/ /deployments/lib/
COPY --from=builder --chown=185 build/quarkus-app/*.jar /deployments/ COPY --from=builder build/quarkus-app/*.jar /deployments/
COPY --from=builder --chown=185 build/quarkus-app/app/ /deployments/app/ COPY --from=builder build/quarkus-app/app/ /deployments/app/
COPY --from=builder --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/ COPY --from=builder build/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8800 EXPOSE 8300
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
@@ -8,7 +8,7 @@ import org.eclipse.microprofile.openapi.annotations.tags.Tag
@OpenAPIDefinition( @OpenAPIDefinition(
info = Info( info = Info(
title = "Kontor", title = "Kontor",
version = "0.2.0" version = "0.3.0"
) )
) )
class KontorApplication: Application() class KontorApplication: Application()
@@ -1,4 +1,4 @@
quarkus.http.port=8800 quarkus.http.port=8300
quarkus.swagger-ui.always-include=true quarkus.swagger-ui.always-include=true
quarkus.datasource.db-kind=postgresql quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=kontor quarkus.datasource.username=kontor
@@ -14,12 +14,8 @@ FROM alpine/java:21-jdk AS run
RUN mkdir -p /logs RUN mkdir -p /logs
RUN adduser --system appuser COPY --from=builder /build/libs/kontor-spring-0.2.0-SNAPSHOT.jar app.jar
COPY --from=builder --chown=appuser:appuser /build/libs/kontor-spring-0.2.0-SNAPSHOT.jar app.jar
RUN chown appuser:root /logs
EXPOSE 8100 EXPOSE 8100
USER appuser
CMD ["java", "-jar", "-Dspring.profiles.active=prod", "-Dvaadin.productionMode=true", "app.jar"]
CMD ["java", "-jar", "-Dspring.profiles.active=prod", "-Dvaadin.productionMode=true", "app.jar"]
@@ -14,7 +14,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid;
import de.thpeetz.kontor.comics.data.TradePaperback; import de.thpeetz.kontor.comics.data.TradePaperback;
import de.thpeetz.kontor.comics.data.Volume;
@SpringBootTest @SpringBootTest
class TradePaperbackViewTest { class TradePaperbackViewTest {
@@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.UUID;
public interface ProfileRepository extends JpaRepository<Profile, String> { public interface ProfileRepository extends JpaRepository<Profile, String> {
@@ -13,8 +13,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class AdminLayout extends AppLayout { public class AdminLayout extends AppLayout {
@SuppressWarnings("unused")
private final AdminService adminService; private final AdminService adminService;
@SuppressWarnings("unused")
private final SecurityService securityService; private final SecurityService securityService;
public AdminLayout(AdminService adminService, SecurityService securityService) { public AdminLayout(AdminService adminService, SecurityService securityService) {
@@ -1,7 +1,6 @@
package de.thpeetz.kontor.bookshelf; package de.thpeetz.kontor.bookshelf;
import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.sidenav.SideNav;
import com.vaadin.flow.component.sidenav.SideNavItem; import com.vaadin.flow.component.sidenav.SideNavItem;
import com.vaadin.flow.router.RouterLink; import com.vaadin.flow.router.RouterLink;
@@ -6,11 +6,9 @@ import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import de.thpeetz.kontor.bookshelf.data.ArticleAuthorRepository; import de.thpeetz.kontor.bookshelf.data.ArticleAuthorRepository;
import de.thpeetz.kontor.bookshelf.data.Author;
import de.thpeetz.kontor.bookshelf.data.AuthorRepository; import de.thpeetz.kontor.bookshelf.data.AuthorRepository;
import de.thpeetz.kontor.bookshelf.data.BookAuthorRepository; import de.thpeetz.kontor.bookshelf.data.BookAuthorRepository;
import de.thpeetz.kontor.bookshelf.data.BookRepository; import de.thpeetz.kontor.bookshelf.data.BookRepository;
import de.thpeetz.kontor.bookshelf.data.BookshelfPublisher;
import de.thpeetz.kontor.bookshelf.data.BookshelfPublisherRepository; import de.thpeetz.kontor.bookshelf.data.BookshelfPublisherRepository;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -12,9 +12,11 @@ import lombok.extern.slf4j.Slf4j;
public class BookshelfService { public class BookshelfService {
private final AuthorRepository authorRepository; private final AuthorRepository authorRepository;
@SuppressWarnings("unused")
private final ArticleAuthorRepository articleAuthorRepository; private final ArticleAuthorRepository articleAuthorRepository;
private final ArticleRepository articleRepository; private final ArticleRepository articleRepository;
private final BookRepository bookRepository; private final BookRepository bookRepository;
@SuppressWarnings("unused")
private final BookAuthorRepository bookAuthorRepository; private final BookAuthorRepository bookAuthorRepository;
private final BookshelfPublisherRepository publisherRepository; private final BookshelfPublisherRepository publisherRepository;
@@ -15,8 +15,6 @@ import de.thpeetz.kontor.bookshelf.data.Article;
import de.thpeetz.kontor.bookshelf.data.Author; import de.thpeetz.kontor.bookshelf.data.Author;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List;
@Slf4j @Slf4j
public class ArticleForm extends FormLayout { public class ArticleForm extends FormLayout {
@@ -12,16 +12,12 @@ import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent; import com.vaadin.flow.spring.annotation.SpringComponent;
import de.thpeetz.kontor.bookshelf.BookshelfConstants; import de.thpeetz.kontor.bookshelf.BookshelfConstants;
import de.thpeetz.kontor.bookshelf.data.Article; import de.thpeetz.kontor.bookshelf.data.Article;
import de.thpeetz.kontor.bookshelf.data.Book;
import de.thpeetz.kontor.bookshelf.data.BookAuthor;
import de.thpeetz.kontor.bookshelf.services.BookshelfService; import de.thpeetz.kontor.bookshelf.services.BookshelfService;
import de.thpeetz.kontor.common.views.MainLayout; import de.thpeetz.kontor.common.views.MainLayout;
import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.PermitAll;
import lombok.Getter; import lombok.Getter;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import java.util.stream.Collectors;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@PermitAll @PermitAll
@@ -5,9 +5,7 @@ import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.Key; import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout; import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.listbox.ListBox; import com.vaadin.flow.component.listbox.ListBox;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.component.textfield.TextField;
@@ -11,8 +11,10 @@ import de.thpeetz.kontor.security.SecurityService;
public class BookshelfLayout extends AppLayout { public class BookshelfLayout extends AppLayout {
@SuppressWarnings("unused")
private final AdminService adminService; private final AdminService adminService;
@SuppressWarnings("unused")
private final SecurityService securityService; private final SecurityService securityService;
public BookshelfLayout(AdminService adminService, SecurityService securityService) { public BookshelfLayout(AdminService adminService, SecurityService securityService) {
@@ -1,7 +1,6 @@
package de.thpeetz.kontor.bookshelf.views; package de.thpeetz.kontor.bookshelf.views;
import de.thpeetz.kontor.common.views.MainLayout; import de.thpeetz.kontor.common.views.MainLayout;
import de.thpeetz.kontor.common.views.SeparateMainLayout;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Component;
+78
View File
@@ -22,7 +22,11 @@ else
-p 5432:5432 \ -p 5432:5432 \
-p 8100:8100 \ -p 8100:8100 \
-p 8200:8200 \ -p 8200:8200 \
-p 8300:8300 \
-p 8900:8080 \ -p 8900:8080 \
-p 61616:61616 \
-p 8161:8161 \
-p 5672:5672 \
--network bridge --network bridge
fi fi
@@ -33,6 +37,13 @@ else
podman volume create kontor-db podman volume create kontor-db
fi fi
echo "==> Setting up volume activemq-data"
if podman volume exists activemq-data; then
echo " => volume kontor-db exists"
else
podman volume create activemq-data
fi
echo "==> Setting up container postgres" echo "==> Setting up container postgres"
if podman container exists postgres; then if podman container exists postgres; then
if podman ps -q --filter "name=postgres"; then if podman ps -q --filter "name=postgres"; then
@@ -44,8 +55,13 @@ else
-e POSTGRES_DB=kontor \ -e POSTGRES_DB=kontor \
-e POSTGRES_USER=kontor \ -e POSTGRES_USER=kontor \
-v kontor-db:/var/lib/postgresql/data \ -v kontor-db:/var/lib/postgresql/data \
--health-cmd='pg_isready -U kontor || exit 1' \
--health-interval=1s \
--health-timeout=5s \
--health-retries=10 \
postgres:17 postgres:17
fi fi
echo "==> Setting up container adminer" echo "==> Setting up container adminer"
if podman container exists adminer; then if podman container exists adminer; then
if podman ps -q --filter "name=adminer"; then if podman ps -q --filter "name=adminer"; then
@@ -55,3 +71,65 @@ else
podman run -d --replace --pod kontor --name adminer adminer podman run -d --replace --pod kontor --name adminer adminer
fi fi
echo "==> Setting up container activemq"
if podman container exists activemq; then
if podman ps -q --filter "name=activemq"; then
echo " => adminer is running"
fi
else
podman run -d --replace --pod kontor --name activemq \
-v activemq-data:/var/lib/artemis-instance \
docker.io/apache/activemq-artemis:latest-alpine
fi
echo "==> Setting up container kontor-spring"
if podman container exists kontor-spring; then
if podman ps -q --filter "name=kontor-spring"; then
echo " => kontor-spring is running"
fi
else
podman run -d \
--replace \
--pod kontor \
--name kontor-spring \
--label "io.containers.autoupdate=local" \
localhost/kontor-spring:0.3.0
fi
echo "==> Setting up container kontor-api"
if podman container exists kontor-api; then
if podman ps -q --filter "name=kontor-api"; then
echo " => kontor-api is running"
fi
else
podman run -d \
--replace \
--pod kontor \
--name kontor-api \
--label "io.containers.autoupdate=local" \
--label "PODMAN_SYSTEMD_UNIT=container-kontor-api.service" \
--health-cmd='curl -f http://kontor-api:8200/health || exit 1' \
--health-interval=1s \
--health-timeout=5s \
--health-retries=10 \
localhost/kontor-api:0.3.0
fi
echo "==> Setting up container kontor-quarkus"
if podman container exists kontor-quarkus; then
if podman ps -q --filter "name=kontor-quarkus"; then
echo " => kontor-quarkus is running"
fi
else
podman run -d \
--replace \
--pod kontor \
--name kontor-quarkus \
--label "io.containers.autoupdate=local" \
--label "PODMAN_SYSTEMD_UNIT=container-kontor-quarkus.service" \
--health-cmd='curl -f http://kontor-api:8300/q/health || exit 1' \
--health-interval=1s \
--health-timeout=5s \
--health-retries=10 \
localhost/kontor-quarkus:0.3.0
fi
-2
View File
@@ -10,8 +10,6 @@ echo "==> Stopping and removing pod kontor"
if podman pod exists kontor; then if podman pod exists kontor; then
podman pod stop kontor podman pod stop kontor
podman pod rm kontor podman pod rm kontor
podman rm postgres
podman rm adminer
fi fi
script/setup script/setup