This commit is contained in:
Халтобин Евгений 2024-09-26 21:04:50 +03:00
parent 9e4cf5450b
commit 6601a1c5b0
16 changed files with 192 additions and 118 deletions

View file

@ -1,11 +1,14 @@
ARG BUILDER_IMAGE=registry.altlinux.org/basealt/altsp:c10f1 ARG BUILDER_IMAGE=registry-dev.pgs.rtlabs.ru/ervu/micord-deps:0.0.1-sha288d758c
ARG RUNTIME_IMAGE=tomee:8.0.16-jre17-webprofile ARG RUNTIME_IMAGE=registry-dev.pgs.rtlabs.ru/basealt/altsp:c10f1
FROM $BUILDER_IMAGE AS builder FROM $BUILDER_IMAGE AS builder
ARG MVN_FLAGS="-Pprod" ARG MVN_FLAGS="-Pprod -DexecuteNpmInstall=false"
RUN apt-get update \ RUN rm -f /etc/apt/sources.list.d/* \
&& echo "rpm http://nexus-dev.pgs.rtlabs.ru repository/alt-c10f1-classic/x86_64 classic" > /etc/apt/sources.list \
&& echo "rpm http://nexus-dev.pgs.rtlabs.ru repository/alt-c10f1-classic/noarch classic" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install git glibc-locales java-17-openjdk-devel maven node \ && apt-get -y install git glibc-locales java-17-openjdk-devel maven node \
&& apt-get clean && apt-get clean
@ -16,19 +19,51 @@ ENV LC_ALL ru_RU.UTF-8
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN mkdir -p $HOME/.m2 \ #RUN mkdir -p $HOME/.m2 \
&& cp -f config/pgs-settings.xml $HOME/.m2/settings.xml \ # && cp -f config/pgs-settings.xml $HOME/.m2/settings.xml \
&& cp -f config/pgs-npmrc frontend/.npmrc \ # && cp -f config/pgs-npmrc frontend/.npmrc \
&& mvn clean package -T4C ${MVN_FLAGS} # && mvn clean package -T4C ${MVN_FLAGS}
#RUN ln -s /root/.npm /app/frontend/node_modules
RUN mvn clean \
&& mvn package -T4C ${MVN_FLAGS}
FROM $RUNTIME_IMAGE FROM $RUNTIME_IMAGE
ARG ADMIN_PASSWORD=Secr3t ARG ADMIN_PASSWORD=Secr3t
COPY config/tomcat/tomee /usr/local/tomee COPY --from=builder /usr/lib/locale/ru_RU /usr/lib/locale/ru_RU
COPY --from=builder /usr/lib/locale/ru_RU.utf8 /usr/lib/locale/ru_RU.utf8
COPY --from=builder /usr/share/locale/ru_RU /usr/share/locale/ru_RU
RUN rm -rf /usr/local/tomee/webapps/ROOT \ COPY config/entrypoint.sh /entrypoint.sh
&& cat /usr/local/tomee/conf/webbpm.properties >> /usr/local/tomee/conf/catalina.properties \
&& sed -i -r "s/<must-be-changed>/$ADMIN_PASSWORD/g" /usr/local/tomee/conf/tomcat-users.xml
COPY --from=builder /app/backend/target/dashboard*.war /usr/local/tomee/webapps/dashboard.war RUN rm -f /etc/apt/sources.list.d/* \
&& echo "rpm http://nexus-dev.pgs.rtlabs.ru repository/alt-c10f1-classic/x86_64 classic" > /etc/apt/sources.list \
&& echo "rpm http://nexus-dev.pgs.rtlabs.ru repository/alt-c10f1-classic/noarch classic" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install java-17-openjdk-headless tomcat tomcat-webapps tomcat-admin-webapps \
&& apt-get clean \
&& rm -f /var/cache/apt/*.bin \
&& rm -f /var/lib/apt/lists/update* \
&& chmod +x /entrypoint.sh
ENV JAVA_HOME=/usr/lib/jvm/java
ENV LANG=ru_RU.UTF-8
ENV LANGUAGE=ru_RU.UTF-8
ENV LC_ALL=ru_RU.UTF-8
COPY config/tomcat /
RUN cat /etc/tomcat/webbpm.properties >> /etc/tomcat/catalina.properties \
&& sed -i -r "s/<must-be-changed>/$ADMIN_PASSWORD/g" /etc/tomcat/tomcat-users.xml \
&& chown -R tomcat:tomcat /var/lib/tomcat/webapps
COPY --from=builder /app/backend/target/dashboard*.war /var/lib/tomcat/webapps/dashboard.war
USER tomcat
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]

1
config/.gitignore vendored
View file

@ -1,2 +1,3 @@
/*.ear /*.ear
/*.jar /*.jar
/*.war

71
config/config.yaml Normal file
View file

@ -0,0 +1,71 @@
name: ervu-dashboard-backend
replicaCount: 1
resources:
requests:
memory: '256Mi'
cpu: '50m'
limits:
memory: '2Gi'
cpu: '1'
ports:
- name: http
containerPort: 8080
services:
- name: '{{ $.Values.name }}'
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 8080
postgres:
database: 'ervu-dashboard'
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 8080
initialDelaySeconds: 30
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
httpGet:
path: /ul/version
port: 8080
initialDelaySeconds: 30
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 5
ingress:
- name: '{{ $.Values.name }}'
annotations:
ingress.kubernetes.io/add-base-url: 'true'
labels:
app/name: ervu-lkrp-ul
rules:
- host: 'dashboard-ervu-dev.pgs.rtlabs.ru'
http:
paths:
- path: /ul
pathType: Prefix
backend:
service:
name: '{{ $.Values.name }}'
port:
name: http
- path: /manager
pathType: Prefix
backend:
service:
name: '{{ $.Values.name }}'
port:
name: http

6
config/entrypoint.sh Normal file
View file

@ -0,0 +1,6 @@
#! /bin/bash
. /etc/tomcat/tomcat.conf
. /etc/sysconfig/tomcat
/usr/libexec/tomcat/server start

View file

@ -1 +0,0 @@
registry=https://nexus-dev.pgs.rtlabs.ru/content/groups/group-npm/

View file

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/settings/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>mirror-micord</id>
<mirrorOf>micord</mirrorOf>
<name>mirror-micord</name>
<url>https://nexus-dev.pgs.rtlabs.ru/repository/maven-micord</url>
</mirror>
<mirror>
<id>mirror-micord-public</id>
<mirrorOf>micord-public</mirrorOf>
<name>mirror-micord-public</name>
<url>https://nexus-dev.pgs.rtlabs.ru/repository/maven-public</url>
</mirror>
</mirrors>
</settings>

View file

@ -1,7 +0,0 @@
TZ=Europe/Moscow
# App datasource
DB_APP_USERNAME=ervu-dashboard
DB_APP_PASSWORD=ervu-dashboard
DB_APP_HOST=db
DB_APP_PORT=5432
DB_APP_NAME=ervu-dashboard

View file

@ -0,0 +1,8 @@
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS \
-Ddb.host=${PG_HOST:-db} \
-Ddb.port=${PG_PORT:-5432} \
-Ddb.name=${PG_DATABASE:-app} \
-Ddb.username=${PG_USER:-app_user} \
-Ddb.password=${PG_PASSWORD:-apppassword} \
"
export JDK_JAVA_OPTIONS

View file

@ -29,8 +29,8 @@
<Manager pathname="" /> <Manager pathname="" />
--> -->
<Resource name="java:/webbpm/AppDS" auth="Container" <Resource name="webbpm/AppDS" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://${db.app.host}:${db.app.port}/${db.app.name}" url="jdbc:postgresql://${db.host}:${db.port}/${db.name}"
username="${db.app.username}" password="${db.app.password}" maxTotal="20" maxIdle="10" maxWaitMillis="-1"/> username="${db.username}" password="${db.password}" maxTotal="20" maxIdle="10" maxWaitMillis="-1"/>
</Context> </Context>

View file

@ -0,0 +1,52 @@
# System-wide configuration file for tomcat services
# This will be loaded by systemd as an environment file,
# so please keep the syntax. For shell expansion support
# place your custom files as /etc/tomcat/conf.d/*.conf
#
# There are 2 "classes" of startup behavior in this package.
# The old one, the default service named tomcat.service.
# The new named instances are called tomcat@instance.service.
#
# Use this file to change default values for all services.
# Change the service specific ones to affect only one service.
# For tomcat.service it's /etc/sysconfig/tomcat, for
# tomcat@instance it's /etc/sysconfig/tomcat@instance.
# This variable is used to figure out if config is loaded or not.
TOMCAT_CFG_LOADED="1"
# In new-style instances, if CATALINA_BASE isn't specified, it will
# be constructed by joining TOMCATS_BASE and NAME.
TOMCATS_BASE="/var/lib/tomcats/"
# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/jre"
# Where your tomcat installation lives
CATALINA_HOME="/usr/share/tomcat"
# System-wide tmp
CATALINA_TMPDIR="/var/cache/tomcat/temp"
# You can pass some parameters to java here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
# Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=/usr/lib"
# Set default javax.sql.DataSource factory to apache commons one. See rhbz#1214381
#JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"
JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"
# You can change your tomcat locale here
#LANG="en_US"
# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"
# SHUTDOWN_WAIT has been deprecated. To change the shutdown wait time, set
# TimeoutStopSec in tomcat.service.
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)

View file

@ -1,4 +1,5 @@
# WebBPM properties # WebBPM properties
#
authentication.method=form authentication.method=form
@ -6,6 +7,8 @@ bpmn.enable=false
fias.enable=false fias.enable=false
gar.enable=false gar.enable=false
mail.jndi.resource.name=
reset_password.mail.template.path=mail/reset_password.html reset_password.mail.template.path=mail/reset_password.html
security.password.regex=^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]+$ security.password.regex=^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]+$

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
export JAVA_OPTS="$JAVA_OPTS \
-Ddb.app.host=${DB_APP_HOST:-db} \
-Ddb.app.port=${DB_APP_PORT:-5432} \
-Ddb.app.name=${DB_APP_NAME:-app} \
-Ddb.app.username=${DB_APP_USERNAME:-app_user} \
-Ddb.app.password=${DB_APP_PASSWORD:-apppassword} \
"

View file

@ -1,32 +0,0 @@
"use strict";
exports.__esModule = true;
var fs = require('fs');
var mfeBaseUrlKey = 'MFE_BASE_URL';
var srcUrlRegex = /url\((\\?["'])?(?!data:)\S+(\\?["'])?\)/g;
function normalizeCssPaths(params) {
params.paths = params.paths ? params.paths : [];
params.paths.forEach(function (path) { return normalizeCssPath(path, params.outDir); });
}
exports.normalizeCssPaths = normalizeCssPaths;
function normalizeCssPath(path, outputDirectory) {
console.log("Start processing " + path);
var css = fs.readFileSync(path, 'utf8');
var counter = 0;
var processedCss = css.replace(srcUrlRegex, function (srcUrl) {
if (srcUrl.search(outputDirectory) != -1)
return srcUrl;
var fileName = getFileName(srcUrl);
var processedUrl = "url('" + outputDirectory + "/" + fileName + "')";
counter++;
console.log("Replaced " + srcUrl + " -> " + processedUrl);
return processedUrl;
});
console.log("Replaced " + counter + " urls");
fs.writeFileSync(path, processedCss);
}
function getFileName(srcUrl) {
var url = srcUrl.substring(4, srcUrl.length - 1); // unbox 'url(...)'
url = url.replace(/(\\?["'])/g, '');
var urlPaths = url.split('/');
return urlPaths[urlPaths.length - 1].split('?')[0];
}

View file

@ -1,33 +0,0 @@
const fs = require('fs');
const srcUrlRegex = /url\((\\?["'])?(?!data:)\S+(\\?["'])?\)/g;
export function normalizeCssPaths(params: {paths: string[], outDir: string}) {
params.paths = params.paths ? params.paths : [];
params.paths.forEach(path => normalizeCssPath(path, params.outDir));
}
function normalizeCssPath(path: string, outputDirectory: string) {
console.log(`Start processing ${path}`);
const css: string = fs.readFileSync(path, 'utf8');
let counter = 0;
const processedCss = css.replace(srcUrlRegex, (srcUrl: string) => {
if (srcUrl.search(outputDirectory) != -1) return srcUrl;
let fileName = getFileName(srcUrl);
let processedUrl = `url('${outputDirectory}/${fileName}')`;
counter++;
console.log(`Replaced ${srcUrl} -> ${processedUrl}`);
return processedUrl;
});
console.log(`Replaced ${counter} urls`);
fs.writeFileSync(path, processedCss);
}
function getFileName(srcUrl: string): string {
let url = srcUrl.substring(4, srcUrl.length - 1); // unbox 'url(...)'
url = url.replace(/(\\?["'])/g, '');
let urlPaths = url.split('/');
return urlPaths[urlPaths.length - 1].split('?')[0];
}