<profiles>
<profile>
<id>production</id>
<properties>
<vaadin.productionMode>true</vaadin.productionMode>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Setup
Docker Setup
Beim Bereitstellen und Deployen der Anwendung in Docker-Containern ist zu berücksichtigen, dass die Anwendung als .jar deployt wird, die Produktdaten jedoch in entpackter Form in den Container kopiert und konfiguriert werden. Hierfür muss zunächst in der pom.xml
der vaadin.productionMode
auf true
gesetzt werden.
Beispiel Dockerfile
:
FROM eclipse-temurin:21-jre-jammy
RUN apt-get update \
&& ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata
ARG UID=999
ARG GID=999
ENV JAVA_TOOL_OPTIONS "-Xms480m -Xmx1024m"
RUN groupadd --gid $GID spring \
&& useradd -r -m -d /opt/spring -s /sbin/nologin --gid $GID --uid $UID -c "Spring user" spring \
&& chmod 755 /opt/spring \
&& mkdir -p /var/opt/spring \
&& chown spring: /var/opt/spring \
&& chmod 755 /var/opt/spring
WORKDIR /opt/spring
COPY ${PATH_TO_APPLICATION_JAR} application.jar
COPY ${PATH_TO_PRODUCT_FOLDER} /var/opt/spring/produkte
RUN chown -R spring: /var/opt/spring
USER $UID
EXPOSE 8080
CMD ["java", \
"-Dspring.profiles.active=production", \
"-jar", \
"application.jar", \
"--server.port=8080", \
"--server.forward-headers-strategy=FRAMEWORK"]
Beispiel docker-compose.yml
:
version: '2.4'
services:
productdesigner-sample:
container_name: ${CONTAINER_NAME}-sample
build:
context: ../
dockerfile: ./path/to/Dockerfile
args:
- PATH_TO_APPLICATION_JAR=${PATH_TO_APPLICATION_JAR}
- PATH_TO_PRODUCT_FOLDER=${PATH_TO_PRODUCT_FOLDER}
environment:
SPRING_PROFILES_ACTIVE: production
ips-product-designer.ips-project-path: /var/opt/spring/produkte
labels:
url: ${CONTAINER_NAME}-sample
entry-path: ui
networks:
default:
name: network-${CONTAINER_NAME}
labels:
retention: ${CONTAINER_RETENTION}