deployment_files

This commit is contained in:
2026-09-16 18:41:57 +00:00
parent d4c9a204a8
commit a1cef9aecc
10 changed files with 967 additions and 107 deletions
@@ -1,105 +1,102 @@
# File is used by sprigboot # File is used by sprigboot
server.contextPath=/* server.contextPath=/*
server.port=9292 server.port=9292
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/webui/ spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/webui/
spring.banner.location=classpath:banner_txt.txt spring.banner.location=classpath:banner_txt.txt
#Temporary disable security to enable it remove this #Temporary disable security to enable it remove this
#security.ignored=/** #security.ignored=/**
springfox.documentation.swagger.v2.path=/api-docs springfox.documentation.swagger.v2.path=/api-docs
spring.jackson.date-format=yyyy-MM-dd spring.jackson.date-format=yyyy-MM-dd
chatgpt.api.url=https://api.openai.com/v1/completions chatgpt.api.url=https://api.openai.com/v1/completions
chatgpt.api.key=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 chatgpt.api.key=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
System.Net.ServicePointManager.Expect100Continue = false; System.Net.ServicePointManager.Expect100Continue = false;
#spring.jpa.hibernate.ddl-auto=none #spring.jpa.hibernate.ddl-auto=none
#spring.jpa.hibernate.ddl-auto=update #spring.jpa.hibernate.ddl-auto=update
#spring.datasource.continue-on-error=false #spring.datasource.continue-on-error=false
# **** MY SQL DATABASE CONNECTION **** # **** MY SQL DATABASE CONNECTION ****
spring.datasource.url=jdbc:mysql://realit-prod.cj462uqsa4mz.ap-south-1.rds.amazonaws.com:3306/realnet_CNSBENEW?createDatabaseIfNotExist=true spring.datasource.url=jdbc:mysql://157.66.191.31:3306/dnam?createDatabaseIfNotExist=true
spring.datasource.username=cnsdev spring.datasource.username=cnsdev
spring.datasource.password=cnsdevprod1212 spring.datasource.password=cnsdev7304
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
# Prefix Path server.servlet.contextPath=/back
#spring.jpa.show-sql=true #spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.proc.param_null_passing=true spring.jpa.properties.hibernate.proc.param_null_passing=true
# **********paytm dependency ****** # **********paytm dependency ******
razorpay.api.key=rzp_test_xVnrBUjJWTEH0r razorpay.api.key=rzp_test_xVnrBUjJWTEH0r
razorpay.api.secret=evTXkIFcgpVtiLa1P7M7CIox razorpay.api.secret=evTXkIFcgpVtiLa1P7M7CIox
#***** MAIL SENDER #***** MAIL SENDER
spring.mail.host=smtp.gmail.com spring.mail.host=smtp.gmail.com
spring.mail.username=realitmailsender@gmail.com spring.mail.username=realitmailsender@gmail.com
spring.mail.password=epnmhzsccotnyozf spring.mail.password=epnmhzsccotnyozf
spring.mail.port=587 spring.mail.port=587
#spring.mail.properties.mail.smtp.auth=true #spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.starttls.required=true
# JACKSON # JACKSON
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
spring.mail.properties.mail.smtp.auth = true spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.socketFactory.port = 465 spring.mail.properties.mail.smtp.socketFactory.port = 465
spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback = false spring.mail.properties.mail.smtp.socketFactory.fallback = false
#******* MULTIPART RESOLVER #******* MULTIPART RESOLVER
spring.servlet.multipart.enabled=true spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=100MB spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB spring.servlet.multipart.max-request-size=100MB
#***************OAUTH2 SOCIAL LOGIN ********* #***************OAUTH2 SOCIAL LOGIN *********
# Social login provider props # Social login provider props
spring.security.oauth2.client.registration.google.clientId=437023664181-0lm0ipgip3qbhga4nd7o4128jv4g2nv9.apps.googleusercontent.com spring.security.oauth2.client.registration.google.clientId=437023664181-0lm0ipgip3qbhga4nd7o4128jv4g2nv9.apps.googleusercontent.com
spring.security.oauth2.client.registration.google.clientSecret=I1HPyUqdJ9UONu45W1_wwfww spring.security.oauth2.client.registration.google.clientSecret=I1HPyUqdJ9UONu45W1_wwfww
spring.security.oauth2.client.registration.google.scope=profile, email spring.security.oauth2.client.registration.google.scope=profile, email
spring.security.oauth2.client.registration.linkedin.clientId=<your-client-id> spring.security.oauth2.client.registration.linkedin.clientId=<your-client-id>
spring.security.oauth2.client.registration.linkedin.clientSecret=<your-client-secret> spring.security.oauth2.client.registration.linkedin.clientSecret=<your-client-secret>
spring.security.oauth2.client.registration.linkedin.client-authentication-method=post spring.security.oauth2.client.registration.linkedin.client-authentication-method=post
spring.security.oauth2.client.registration.linkedin.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.linkedin.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.linkedin.scope=r_liteprofile, r_emailaddress spring.security.oauth2.client.registration.linkedin.scope=r_liteprofile, r_emailaddress
spring.security.oauth2.client.registration.linkedin.redirect-uri={baseUrl}/login/oauth2/code/{registrationId} spring.security.oauth2.client.registration.linkedin.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
spring.security.oauth2.client.registration.linkedin.client-name=Linkedin spring.security.oauth2.client.registration.linkedin.client-name=Linkedin
spring.security.oauth2.client.registration.linkedin.provider=linkedin spring.security.oauth2.client.registration.linkedin.provider=linkedin
spring.security.oauth2.client.provider.linkedin.authorization-uri=https://www.linkedin.com/oauth/v2/authorization spring.security.oauth2.client.provider.linkedin.authorization-uri=https://www.linkedin.com/oauth/v2/authorization
spring.security.oauth2.client.provider.linkedin.token-uri=https://www.linkedin.com/oauth/v2/accessToken spring.security.oauth2.client.provider.linkedin.token-uri=https://www.linkedin.com/oauth/v2/accessToken
spring.security.oauth2.client.provider.linkedin.user-info-uri=https://api.linkedin.com/v2/me spring.security.oauth2.client.provider.linkedin.user-info-uri=https://api.linkedin.com/v2/me
spring.security.oauth2.client.provider.linkedin.user-name-attribute=id spring.security.oauth2.client.provider.linkedin.user-name-attribute=id
linkedin.email-address-uri=https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~)) linkedin.email-address-uri=https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
app.auth.tokenSecret=926D96C90030DD58429D2751AC1BDBBC app.auth.tokenSecret=926D96C90030DD58429D2751AC1BDBBC
app.auth.tokenExpirationMsec=864000000 app.auth.tokenExpirationMsec=864000000
# After successfully authenticating with the OAuth2 Provider, # After successfully authenticating with the OAuth2 Provider,
# we'll be generating an auth token for the user and sending the token to the # we'll be generating an auth token for the user and sending the token to the
# redirectUri mentioned by the frontend client in the /oauth2/authorization request. # redirectUri mentioned by the frontend client in the /oauth2/authorization request.
# We're not using cookies because they won't work well in mobile clients. # We're not using cookies because they won't work well in mobile clients.
app.oauth2.authorizedRedirectUris=http://localhost:8081/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect app.oauth2.authorizedRedirectUris=http://localhost:8081/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
# projectPath=@project.basedir@ # projectPath=@project.basedir@
# angularProjectPath=@project.basedir@/webui # angularProjectPath=@project.basedir@/webui
projectPath=/data projectPath=/data
angularProjectPath=/data/webui angularProjectPath=/data/webui
BACKEND_PORTAL_DOMAIN=http://157.66.191.31:30166 BACKEND_PORTAL_DOMAIN=http://157.66.191.31:30166
@@ -23,5 +23,5 @@ class ApiConstants {
static const getSystemParameters = '$baseUrl/sysparam/getSysParams'; static const getSystemParameters = '$baseUrl/sysparam/getSysParams';
static const updateSystemParams = '$baseUrl/sysparam/updateSysParams'; static const updateSystemParams = '$baseUrl/sysparam/updateSysParams';
static const baseUrl = 'http://localhost:9292'; static const baseUrl ='http://157.66.191.31:46219/back';
} }
+238
View File
@@ -0,0 +1,238 @@
########################################
# Combined Single Container
# Flutter (APK) + Spring Boot + MySQL
########################################
########################################
# Global build arguments (must be re-declared
# in every stage that needs them)
########################################
ARG GITEA_USER
ARG GITEA_PASS
ARG GITEA_URL=157.66.191.31:3000
ARG GITEA_ORG
ARG REPO_NAME
ARG GIT_BRANCH=main
ARG JAR_NAME=app-1.0.0.jar
# Subpath INSIDE the "*-b" folder where the pom.xml root lives
# e.g. authsec_springboot/backend
ARG BACKEND_SUBPATH
# Subpath INSIDE the "*-f" folder where the flutter project
# (pubspec.yaml) root lives
# e.g. authsec_flutter_new/frontend/flutter_new
ARG FRONTEND_SUBPATH
# Final apk name copied into the image
ARG APK_NAME=app-release.apk
########################################
# Stage 1 - Clone Repository + Auto-discover modules
########################################
FROM alpine/git:latest AS source
ARG GITEA_USER
ARG GITEA_PASS
ARG GITEA_URL
ARG GITEA_ORG
ARG REPO_NAME
ARG GIT_BRANCH
WORKDIR /src
RUN git clone --branch ${GIT_BRANCH} --single-branch \
http://${GITEA_USER}:${GITEA_PASS}@${GITEA_URL}/${GITEA_ORG}/${REPO_NAME}.git
########################################
# Auto-discover backend (*-b), frontend (*-f), and
# db (*-d) top-level folders, regardless of the service
########################################
RUN set -e; \
BACKEND_DIR=$(find /src/${REPO_NAME} -maxdepth 1 -type d -name "*-b" | head -n1); \
FRONTEND_DIR=$(find /src/${REPO_NAME} -maxdepth 1 -type d -name "*-f" | head -n1); \
DB_DIR=$(find /src/${REPO_NAME} -maxdepth 1 -type d -name "*-d" | head -n1); \
if [ -z "$BACKEND_DIR" ]; then \
echo "ERROR: No backend module folder (ending in -b) found under /src/${REPO_NAME}"; \
ls -la /src/${REPO_NAME}; \
exit 1; \
fi; \
if [ -z "$FRONTEND_DIR" ]; then \
echo "ERROR: No frontend module folder (ending in -f) found under /src/${REPO_NAME}"; \
ls -la /src/${REPO_NAME}; \
exit 1; \
fi; \
if [ -z "$DB_DIR" ]; then \
echo "WARNING: No db module folder (ending in -d) found under /src/${REPO_NAME}"; \
fi; \
echo "Backend module found : $BACKEND_DIR"; \
echo "Frontend module found : $FRONTEND_DIR"; \
echo "DB module found : $DB_DIR"; \
ln -s "$BACKEND_DIR" /src/backend-module; \
ln -s "$FRONTEND_DIR" /src/frontend-module; \
if [ -n "$DB_DIR" ]; then ln -s "$DB_DIR" /src/db-module; fi
########################################
# Stage 2 - Backend Build
########################################
FROM maven:3.9.3-eclipse-temurin-8 AS backend-build
ARG BACKEND_SUBPATH
WORKDIR /workspace/backend
COPY --from=source \
/src/backend-module/${BACKEND_SUBPATH}/ \
./
RUN mvn clean package -DskipTests
########################################
# Stage 3 - Frontend Build (Flutter APK)
########################################
FROM ghcr.io/cirruslabs/flutter:3.27.3 AS frontend-build
ARG FRONTEND_SUBPATH
WORKDIR /workspace/frontend
COPY --from=source \
/src/frontend-module/${FRONTEND_SUBPATH}/ \
./
RUN flutter pub get
# Optional project-specific cleanup script, skipped if absent
RUN if [ -f ./remove_unused.sh ]; then \
chmod +x ./remove_unused.sh && ./remove_unused.sh; \
else \
echo "remove_unused.sh not found, skipping"; \
fi
RUN flutter clean
RUN flutter pub get
RUN flutter build apk --target-platform android-arm64
########################################
# Stage 4 - Runtime
########################################
FROM ubuntu:22.04
ARG REPO_NAME
ARG JAR_NAME
ARG APK_NAME
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
openjdk-17-jre \
mysql-server \
nginx \
supervisor \
curl \
wget \
git \
nano \
net-tools \
procps \
ca-certificates && \
rm -f /etc/nginx/conf.d/default.conf && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
########################################
# Create Directories
########################################
RUN mkdir -p \
/opt/backend \
/opt/database \
/usr/share/nginx/html \
/var/log/supervisor
########################################
# Backend
########################################
COPY --from=backend-build \
/workspace/backend/target/${JAR_NAME} \
/opt/backend/app.jar
########################################
# SQL Files (optional - only copied if present in repo)
########################################
COPY --from=source \
/src/backend-module/${BACKEND_SUBPATH}/src/main/resources/schema.sql \
/opt/database/schema.sql
COPY --from=source \
/src/backend-module/${BACKEND_SUBPATH}/src/main/resources/data.sql \
/opt/database/data.sql
########################################
# Frontend (APK served for download)
########################################
COPY --from=frontend-build \
/workspace/frontend/build/app/outputs/flutter-apk/app-release.apk \
/usr/share/nginx/html/${APK_NAME}
########################################
# Configuration Files
########################################
COPY --from=source \
/src/${REPO_NAME}/sureops/entrypoint.sh \
/usr/local/bin/entrypoint.sh
COPY --from=source \
/src/${REPO_NAME}/sureops/init-db.sh \
/usr/local/bin/init-db.sh
COPY --from=source \
/src/${REPO_NAME}/sureops/supervisord.conf \
/etc/supervisor/conf.d/supervisord.conf
COPY --from=source \
/src/${REPO_NAME}/sureops/nginx.conf \
/etc/nginx/nginx.conf
########################################
# Permissions
########################################
RUN chmod +x /usr/local/bin/entrypoint.sh && \
chmod +x /usr/local/bin/init-db.sh
########################################
# Ports
########################################
EXPOSE 80
EXPOSE 9292
########################################
# Start
########################################
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+85
View File
@@ -0,0 +1,85 @@
#!/bin/bash
set -e
echo "========================================"
echo " Starting Combined Application Container"
echo " Flutter APK + Backend + MySQL"
echo "========================================"
# ========================================
# Project-specific DB name
# Fill this in per project so each combined
# container keeps its own isolated local DB
# and never collides with another project.
# ========================================
DB_NAME="<PRJ_DB_NAME>"
# ========================================
# Start MySQL
# ========================================
echo "Starting MySQL..."
service mysql start
echo "Waiting for MySQL..."
until mysqladmin ping -h "127.0.0.1" --silent; do
echo "MySQL is not ready yet..."
sleep 2
done
echo "MySQL Started Successfully."
echo "Setting MySQL root password..."
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Root@1234';" 2>/dev/null || \
mysqladmin -u root password 'Root@1234' 2>/dev/null || \
echo "Root password already set or using socket auth, continuing..."
# ========================================
# Initialize Database
# ========================================
if [ -f "/usr/local/bin/init-db.sh" ]; then
echo "========================================"
echo " Initializing Database"
echo "========================================"
chmod +x /usr/local/bin/init-db.sh
DB_NAME="${DB_NAME}" /usr/local/bin/init-db.sh
echo "Database Initialization Completed."
else
echo "init-db.sh not found."
echo "Skipping database initialization."
fi
# ========================================
# Force Backend to use local combined-container MySQL
# (overrides application.properties datasource without
# touching the template file, so standalone/multi-container
# builds remain unaffected)
# ========================================
export SPRING_DATASOURCE_URL="jdbc:mysql://127.0.0.1:3306/${DB_NAME}?createDatabaseIfNotExist=true"
export SPRING_DATASOURCE_USERNAME="root"
export SPRING_DATASOURCE_PASSWORD="Root@1234"
# ========================================
# Start Supervisor
# ========================================
echo "========================================"
echo " Starting Supervisor"
echo "========================================"
exec /usr/bin/supervisord \
-n \
-c /etc/supervisor/conf.d/supervisord.conf
+227
View File
@@ -0,0 +1,227 @@
undefined#!/bin/bash
set -Eeuo pipefail
SECONDS=0
########################################
# Error Handling
########################################
trap 'echo "ERROR: Script failed at line ${LINENO}. Command: ${BASH_COMMAND}" >&2' ERR
########################################
# Project Identity
# NOTE: Fill these in per-project. Do not
# hardcode values here that other projects
# also use, to avoid collisions.
########################################
PRJ_NAME="mytest16sep-frontend-f"
IMAGE_PROJECT_NAME="${PRJ_NAME}"
########################################
# Gitea Source Repository
########################################
GITEA_USER="risadmin_prod"
GITEA_PASS="adminprod1234"
GITEA_URL="http://157.66.191.31:3000"
GITEA_URL="${GITEA_URL#http://}"
GITEA_ORG="risadmin_prod"
GITEA_EMAIL="ganeshk@dekatc.com"
REPO_NAME="mytest16sep"
GIT_BRANCH=main
########################################
# Module Paths (per project, inside -b / -f dirs)
########################################
JAR_NAME=app-1.0.0.jar
BACKEND_SUBPATH="<BACKEND_SUBPATH>" # e.g. authsec_springboot/backend
FRONTEND_SUBPATH="<FRONTEND_SUBPATH>" # e.g. authsec_flutter_new/frontend/flutter_new
APK_NAME=app-release.apk
########################################
# Docker Registry
########################################
DOCKER_USER=risadmin_prod
DOCKER_PASS=adminprod1234
DOCKER_URL=157.66.191.31:3000
DOCKER_TAG=1.0
########################################
# Build Path
########################################
PATH_DIR="/data/66065_1789584033113/sureops"
########################################
# Image Names
########################################
IMAGE_NAME="${DOCKER_URL}/${DOCKER_USER}/${IMAGE_PROJECT_NAME}:${DOCKER_TAG}"
LATEST_IMAGE="${DOCKER_URL}/${DOCKER_USER}/${IMAGE_PROJECT_NAME}:latest"
########################################
# Display Configuration
########################################
echo "=========================================="
echo " SINGLE CONTAINER BUILD (Flutter + SpringBoot + MySQL)"
echo "=========================================="
echo "Project Name : ${PRJ_NAME}"
echo "Container Name : ${IMAGE_PROJECT_NAME}"
echo "Repository : ${GITEA_ORG}/${REPO_NAME}"
echo "Branch : ${GIT_BRANCH}"
echo "Docker Image : ${IMAGE_NAME}"
echo "Latest Image : ${LATEST_IMAGE}"
echo "Build Path : ${PATH_DIR}"
echo "=========================================="
########################################
# Validate Configuration
########################################
echo "Validating configuration..."
REQUIRED_VARIABLES=(
"PRJ_NAME"
"GITEA_USER"
"GITEA_PASS"
"GITEA_URL"
"GITEA_ORG"
"REPO_NAME"
"GIT_BRANCH"
"JAR_NAME"
"BACKEND_SUBPATH"
"FRONTEND_SUBPATH"
"DOCKER_USER"
"DOCKER_PASS"
"DOCKER_URL"
"DOCKER_TAG"
"PATH_DIR"
)
for VARIABLE in "${REQUIRED_VARIABLES[@]}"; do
VALUE="${!VARIABLE:-}"
if [[ -z "${VALUE}" ]]; then
echo "ERROR: Required variable '${VARIABLE}' is empty."
exit 1
fi
if [[ "${VALUE}" == "<"*">" ]]; then
echo "ERROR: Variable '${VARIABLE}' still contains placeholder value: ${VALUE}"
exit 1
fi
done
echo "Configuration validation successful."
########################################
# Check Docker
########################################
if ! command -v docker >/dev/null 2>&1; then
echo "ERROR: Docker is not installed or not available in PATH."
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "ERROR: Docker daemon is not running or current user has no permission."
exit 1
fi
########################################
# Change Directory
########################################
if [[ ! -d "${PATH_DIR}" ]]; then
echo "ERROR: Directory not found: ${PATH_DIR}"
exit 1
fi
cd "${PATH_DIR}"
########################################
# Build Docker Image
########################################
echo "=========================================="
echo " BUILDING DOCKER IMAGE"
echo "=========================================="
docker build \
--no-cache \
--build-arg "GITEA_USER=${GITEA_USER}" \
--build-arg "GITEA_PASS=${GITEA_PASS}" \
--build-arg "GITEA_URL=${GITEA_URL}" \
--build-arg "GITEA_ORG=${GITEA_ORG}" \
--build-arg "REPO_NAME=${REPO_NAME}" \
--build-arg "GIT_BRANCH=${GIT_BRANCH}" \
--build-arg "JAR_NAME=${JAR_NAME}" \
--build-arg "BACKEND_SUBPATH=${BACKEND_SUBPATH}" \
--build-arg "FRONTEND_SUBPATH=${FRONTEND_SUBPATH}" \
--build-arg "APK_NAME=${APK_NAME}" \
-t "${IMAGE_NAME}" \
.
echo "Docker build successful."
########################################
# Verify Image
########################################
if ! docker image inspect "${IMAGE_NAME}" >/dev/null 2>&1; then
echo "ERROR: Docker image was not created: ${IMAGE_NAME}"
exit 1
fi
docker images "${IMAGE_NAME}"
########################################
# Docker Registry Login + Push
########################################
if ! echo "${DOCKER_PASS}" | docker login \
--username "${DOCKER_USER}" \
--password-stdin \
"${DOCKER_URL}"; then
echo "ERROR: Docker registry login failed."
exit 1
fi
docker tag "${IMAGE_NAME}" "${LATEST_IMAGE}"
docker push "${IMAGE_NAME}"
docker push "${LATEST_IMAGE}"
docker logout "${DOCKER_URL}" || true
########################################
# Deployment Note
#
# DO NOT RUN CONTAINER HERE.
# Deployment service will perform:
# docker pull / docker stop / docker rm / docker run
########################################
echo "=========================================="
echo " BUILD AND PUSH COMPLETED"
echo "=========================================="
echo "Project Name : ${PRJ_NAME}"
echo "Image : ${IMAGE_NAME}"
echo "Latest Image : ${LATEST_IMAGE}"
DURATION="${SECONDS}"
echo "Total time taken: $((DURATION / 60)) min $((DURATION % 60)) sec"
exit 0
+146
View File
@@ -0,0 +1,146 @@
#!/bin/bash
set -e
# ========================================
# MySQL Configuration
# ========================================
MYSQL_USER="root"
MYSQL_PASS="Root@1234"
# DB_NAME is passed in from entrypoint.sh (per-project, unique).
# Fallback below only used if script is run standalone.
DB_NAME="${DB_NAME:-<PRJ_DB_NAME>}"
SQL_DIR="${SQL_DIR:-/opt/database}"
echo "========================================"
echo " Database Initialization"
echo "========================================"
echo "Database : ${DB_NAME}"
echo "SQL Dir : ${SQL_DIR}"
echo "========================================"
# ========================================
# Create Database
# ========================================
echo "Creating database if not exists..."
mysql \
-u"${MYSQL_USER}" \
-p"${MYSQL_PASS}" \
-e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`;"
echo "Database ready."
# ========================================
# Check Existing Tables
# ========================================
echo "Checking database initialization..."
TABLE_COUNT=$(
mysql \
-u"${MYSQL_USER}" \
-p"${MYSQL_PASS}" \
-N -s \
-e "SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema='${DB_NAME}';"
)
echo "Existing tables: ${TABLE_COUNT}"
# ========================================
# Initialize Database
# ========================================
if [ "${TABLE_COUNT}" -eq 0 ]; then
echo "Fresh database detected."
echo "Searching SQL files in ${SQL_DIR}..."
# ------------------------------------
# Import SQL files in FIXED order:
# schema.sql (structure) MUST run before
# data.sql (inserts), otherwise inserts
# fail with "table doesn't exist".
# ------------------------------------
if [ -d "${SQL_DIR}" ]; then
ORDERED_FILES=("schema.sql" "data.sql")
IMPORTED_ANY=false
for FILE_NAME in "${ORDERED_FILES[@]}"; do
SQL_FILE="${SQL_DIR}/${FILE_NAME}"
if [ -f "${SQL_FILE}" ]; then
echo "----------------------------------------"
echo "Importing: ${SQL_FILE}"
echo "----------------------------------------"
mysql \
-u"${MYSQL_USER}" \
-p"${MYSQL_PASS}" \
"${DB_NAME}" < "${SQL_FILE}"
echo "Imported successfully: ${SQL_FILE}"
IMPORTED_ANY=true
else
echo "Not found, skipping: ${SQL_FILE}"
fi
done
# Import any other .sql files not in the fixed list
OTHER_FILES=$(find "${SQL_DIR}" -maxdepth 1 -type f -name "*.sql" \
! -name "schema.sql" ! -name "data.sql" | sort)
for SQL_FILE in ${OTHER_FILES}; do
echo "----------------------------------------"
echo "Importing (extra): ${SQL_FILE}"
echo "----------------------------------------"
mysql \
-u"${MYSQL_USER}" \
-p"${MYSQL_PASS}" \
"${DB_NAME}" < "${SQL_FILE}"
echo "Imported successfully: ${SQL_FILE}"
IMPORTED_ANY=true
done
if [ "${IMPORTED_ANY}" = false ]; then
echo "No SQL files found."
fi
else
echo "WARNING: SQL directory does not exist:"
echo "${SQL_DIR}"
fi
echo "========================================"
echo " Database initialization completed."
echo "========================================"
else
echo "========================================"
echo " Database already initialized."
echo " Skipping SQL import."
echo "========================================"
fi
+35
View File
@@ -0,0 +1,35 @@
#pulling from github
FROM alpine/git:v2.30.1 AS code
ARG BUILD_ID
ARG GITEA_USER
ARG GITEA_PASS
RUN echo $BUILD_ID
LABEL stage=builder
LABEL build_id=$BUILD_ID
RUN mkdir repo
WORKDIR /repo
RUN git clone http://$GITEA_USER:$GITEA_PASS@157.66.191.31:3000/risadmin_prod/mytest16sep.git
#************* Stage 2 - Maven Build **************
FROM maven:3.9.3 AS mvn
LABEL stage=builder
LABEL build=$BUILD_ID
WORKDIR /workspace/app
COPY --from=code /repo/mytest16sep/mytest16sep-back-b/authsec_springboot/backend/ /workspace/app
RUN mkdir builder/
RUN mvn install -Dmaven.test.skip
#******** Stage 3 - Docker Build *********
#FROM java:8-jdk-alpine
#FROM openjdk:8-jdk-alpine
FROM eclipse-temurin:8-jdk-alpine
LABEL stage=app
LABEL build=$BUILD_ID
RUN mkdir /usr/app
RUN mkdir /data
COPY --from=mvn /workspace/app/target/*jar /usr/app/gtest.jar
RUN mkdir /usr/app/sureops
WORKDIR /usr/app
EXPOSE 9292
ENTRYPOINT ["java", "-jar", "gtest.jar"]
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
PRJ_NAME=mytest16sep-back-b
DOCKER_USER=risadmin_prod
DOCKER_PASS=adminprod1234
DOCKER_URL=157.66.191.31:3000
#********************
REPO_NAME=mytest16sep
GITEA_USER=risadmin_prod
GITEA_PASS=adminprod1234
GITEA_EMAIL=ganeshk@dekatc.com
GIT_BRANCH=main
DOMAIN=157.66.191.31:3000
#WEB-URL-PORT
CONT_PORT=3306
TARGET_PORT=9292
PATH_DIR=/data/66065_1789584033113/sureops/mytest16sep-back-b/deployment
#**********************
cd $PATH_DIR
DOCKER_TAG=1.0
#docker system prune -f
# Stop any existing containers with the same name and ports
docker stop $PRJ_NAME >/dev/null 2>&1 || true
docker rm $PRJ_NAME >/dev/null 2>&1 || true
# Build and push the Docker image
DOCKER_BUILDKIT=0 docker build --no-cache -t $DOCKER_URL/$DOCKER_USER/$PRJ_NAME:$DOCKER_TAG --build-arg GITEA_PASS=adminprod1234 --build-arg GITEA_USER=risadmin_prod .
docker login --username=$DOCKER_USER --password=$DOCKER_PASS $DOCKER_URL
docker tag $DOCKER_URL/$DOCKER_USER/$PRJ_NAME:$DOCKER_TAG $DOCKER_URL/$DOCKER_USER/$PRJ_NAME
docker push $DOCKER_URL/$DOCKER_USER/$PRJ_NAME
docker push $DOCKER_URL/$DOCKER_USER/$PRJ_NAME:$DOCKER_TAG
docker logout $DOCKER_URL
#docker system prune -f
# Deploy the image in a Docker container
#docker run -d --name $PRJ_NAME -p $CONT_PORT:$TARGET_PORT $DOCKER_USER/$PRJ_NAME:$DOCKER_TAG
curl -X GET "http://157.66.191.31:31170/sureops/suredocker/updaterepo?repoName=$REPO_NAME&packageName=$PRJ_NAME"
+49
View File
@@ -0,0 +1,49 @@
events {
worker_connections 768;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
# ==========================================
# APK DOWNLOAD
# Serves the built APK for direct download,
# e.g. http://<host>/app-release.apk
# ==========================================
location / {
autoindex on;
try_files $uri $uri/ =404;
}
location ~ \.apk$ {
add_header Content-Disposition "attachment";
default_type application/vnd.android.package-archive;
}
# ==========================================
# BACKEND (handles /backend/ AND /<any-prefix>/backend/)
# ==========================================
location ~ ^/(?:[^/]+/)*backend/(.*)$ {
proxy_pass http://127.0.0.1:9292/$1$is_args$args;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization $http_authorization;
}
}
}
+46
View File
@@ -0,0 +1,46 @@
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
; ==========================================
; Spring Boot
; ==========================================
[program:springboot]
command=java -jar /opt/backend/app.jar
directory=/opt/backend
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
priority=20
; ==========================================
; Nginx (serves APK download + proxies backend)
; ==========================================
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
priority=30