DEVOPS-1893 New Dockerfile

This commit is contained in:
Pavel Zilke 2024-12-25 00:05:16 +03:00
parent f20520cfd0
commit de343de8f5
3 changed files with 175 additions and 12 deletions

View file

@ -1,25 +1,48 @@
#Dockerfile for TeamCity build "run in docker"
ARG BUILDER_IMAGE=registry.altlinux.org/basealt/altsp:c10f1
ARG BACKEND_IMAGE=repo.micord.ru/alt/alt-tomcat:c10f1-9.0.59-20240903
ARG FRONTEND_IMAGE=nginx:1.24-alpine-slim
FROM repo.micord.ru/alt/alt-tomcat:c10f1-9.0.59-20240917
FROM $BUILDER_IMAGE AS builder
ARG MVN_FLAGS="-Pprod"
RUN apt-get update \
&& apt-get -y install git glibc-locales java-17-openjdk-devel maven node \
&& apt-get clean
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
WORKDIR /app
COPY . .
RUN mkdir -p $HOME/.m2 \
# && cp -f config/pgs-settings.xml $HOME/.m2/settings.xml \
# && cp -f config/pgs-npmrc frontend/.npmrc \
&& mvn clean \
&& mvn package -T4C ${MVN_FLAGS}
FROM $BACKEND_IMAGE AS backend
ARG ADMIN_PASSWORD=Secr3t
USER root
RUN apt-get update \
&& apt-get -y install fonts-ttf-ms
COPY tomcat /
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 root:tomcat /var/lib/tomcat/webapps \
&& chmod g+rw /var/lib/tomcat/webapps
COPY frontend.war /var/lib/tomcat/webapps/ROOT.war
COPY account-applications.war /var/lib/tomcat/webapps/account-applications.war
USER tomcat
EXPOSE 8080
COPY --from=builder /app/backend/target/account-applications.war /var/lib/tomcat/webapps/ul.war
ENTRYPOINT ["/entrypoint.sh"]
FROM backend AS combo
COPY --from=builder /app/frontend/target/frontend*.war /var/lib/tomcat/webapps/ROOT.war
FROM $FRONTEND_IMAGE AS frontend
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /app/frontend/dist /frontend

25
config/Dockerfile.TC Normal file
View file

@ -0,0 +1,25 @@
#Dockerfile for TeamCity build "run in docker"
FROM repo.micord.ru/alt/alt-tomcat:c10f1-9.0.59-20240917
ARG ADMIN_PASSWORD=Secr3t
USER root
RUN apt-get update \
&& apt-get -y install fonts-ttf-ms
COPY 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 root:tomcat /var/lib/tomcat/webapps \
&& chmod g+rw /var/lib/tomcat/webapps
COPY frontend.war /var/lib/tomcat/webapps/ROOT.war
COPY account-applications.war /var/lib/tomcat/webapps/account-applications.war
USER tomcat
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]

115
config/nginx.conf Normal file
View file

@ -0,0 +1,115 @@
include /etc/nginx/modules-enabled.d/*.conf;
worker_processes 10;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
include /etc/nginx/conf-enabled.d/*.conf;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
gzip on;
# text/html doesn't need to be defined there, it's compressed always
gzip_types text/plain text/css text/xml application/x-javascript application/atom+xml;
# gzip_comp_level 9;
include /etc/nginx/sites-enabled.d/*.conf;
log_format nginx_main
'$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$request_filename" "$gzip_ratio" $upstream_response_time server: $host : $document_root $fastcgi_script_name ';
server {
listen 80 default;
access_log /var/log/nginx/access.log nginx_main;
error_log /var/log/nginx/error.log error;
charset utf-8;
client_max_body_size 32m;
##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rdf+xml
application/rss+xml
application/xhtml+xml
application/xml
font/eot
font/otf
font/ttf
image/svg+xml
text/css
text/javascript
text/plain
text/xml;
location / {
root /frontend;
index index.html;
try_files $uri @index;
#Application config
location = /src/resources/app-config.json {
add_header Cache-Control "no-cache";
expires 0;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc|woff2|woff|ttf)$ {
expires 1M;
access_log off;
# max-age must be in seconds
add_header Cache-Control "max-age=2629746, public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "max-age=31556952, public";
}
}
location @index {
root /frontend;
add_header Cache-Control "no-cache";
expires 0;
try_files /index.html =404;
}
location = /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"UP"}';
}
}
}