mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
https://github.com/cskefu/cskefu/issues/775 enable build docker container for cskefu serving api
Signed-off-by: Hai Liang Wang <hai@chatopera.com>
This commit is contained in:
parent
0aa5c64817
commit
4ad2b5641b
@ -1,20 +1,25 @@
|
||||
FROM adoptopenjdk/openjdk15:jdk-15.0.1_9-alpine-slim as build
|
||||
WORKDIR /workspace/app
|
||||
COPY target/core*.jar /workspace/app
|
||||
RUN mkdir -p /workspace/app/dependency && (cd /workspace/app/dependency; jar -xf ../*.jar)
|
||||
FROM chatopera/java:17
|
||||
|
||||
MAINTAINER Hai Liang Wang <h@cskefu.com>
|
||||
# base image is built with config/base/build.sh
|
||||
|
||||
FROM adoptopenjdk/openjdk15:jdk-15.0.1_9-alpine-slim
|
||||
VOLUME /tmp
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG VCS_REF
|
||||
ARG APPLICATION_CUSTOMER_ENTITY
|
||||
ARG APPLICATION_BUILD_DATESTR
|
||||
|
||||
ARG DEPENDENCY=/workspace/app/dependency
|
||||
RUN addgroup --system app_group && adduser --system app_user --ingroup app_group --home /app
|
||||
COPY --from=build --chown=app_user ${DEPENDENCY}/BOOT-INF/lib /app/lib
|
||||
COPY --from=build --chown=app_user ${DEPENDENCY}/META-INF /app/META-INF
|
||||
COPY --chown=app_user target/internal-bundles /app/internal-bundles
|
||||
COPY --from=build --chown=app_user ${DEPENDENCY}/BOOT-INF/classes /app
|
||||
ENV APPLICATION_CUSTOMER_ENTITY=$APPLICATION_CUSTOMER_ENTITY
|
||||
ENV APPLICATION_BUILD_DATESTR=$APPLICATION_BUILD_DATESTR
|
||||
|
||||
USER app_user:app_group
|
||||
WORKDIR /app
|
||||
LABEL org.label-schema.vcs-ref=$VCS_REF \
|
||||
org.label-schema.vcs-url="https://github.com/cskefu/cskefu"
|
||||
|
||||
ENTRYPOINT ["java","-cp","./:lib/*","com.cskefu.serving.api.SampleApplication"]
|
||||
RUN rm -rf /opt/cskefu && mkdir /opt/cskefu
|
||||
COPY ./target/serving-api.jar /opt/cskefu/serving-api.jar
|
||||
COPY ./target/internal-bundles /opt/cskefu/internal-bundles
|
||||
COPY ./assets/*.sh /opt/cskefu
|
||||
RUN chmod +x /opt/cskefu/*.sh
|
||||
|
||||
WORKDIR /opt/cskefu
|
||||
EXPOSE 6500-6700
|
||||
CMD ["./docker-entrypoint.sh"]
|
||||
|
22
server/serving-api/assets/docker-entrypoint.sh
Normal file
22
server/serving-api/assets/docker-entrypoint.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#! /bin/bash
|
||||
###########################################
|
||||
# Contact Center Start
|
||||
###########################################
|
||||
|
||||
# constants
|
||||
baseDir=$(cd `dirname "$0"`;pwd)
|
||||
|
||||
# functions
|
||||
|
||||
# main
|
||||
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
|
||||
cd $baseDir
|
||||
|
||||
# TODO, setup db or upgrade db
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
java -jar serving-api.jar
|
||||
else
|
||||
echo "Fail to resolve mysql database instance."
|
||||
exit 1
|
||||
fi
|
44
server/serving-api/bin/build.sh
Normal file
44
server/serving-api/bin/build.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#! /bin/bash
|
||||
###########################################
|
||||
#
|
||||
###########################################
|
||||
|
||||
# constants
|
||||
baseDir=$(cd `dirname "$0"`;pwd)
|
||||
appHome=$baseDir/..
|
||||
registryPrefix=
|
||||
imagename=cskefu/contact-center
|
||||
|
||||
# functions
|
||||
|
||||
# main
|
||||
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
|
||||
# build
|
||||
cd $appHome
|
||||
if [ -d ../private ]; then
|
||||
registryPrefix=dockerhub.qingcloud.com/
|
||||
fi
|
||||
|
||||
TIMESTAMP=`date "+%Y%m%d.%H%M%S"`
|
||||
PACKAGE_VERSION=`git rev-parse --short HEAD`
|
||||
APPLICATION_CUSTOMER_ENTITY=${APPLICATION_CUSTOMER_ENTITY:-"OpenSource Community"}
|
||||
|
||||
$baseDir/package.sh
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
docker build --build-arg VCS_REF=$PACKAGE_VERSION \
|
||||
--build-arg APPLICATION_BUILD_DATESTR=$TIMESTAMP \
|
||||
--build-arg APPLICATION_CUSTOMER_ENTITY="$APPLICATION_CUSTOMER_ENTITY" \
|
||||
--no-cache \
|
||||
--force-rm=true --tag $registryPrefix$imagename:$PACKAGE_VERSION .
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
docker tag $registryPrefix$imagename:$PACKAGE_VERSION $registryPrefix$imagename:v8
|
||||
else
|
||||
echo "Build contact-center failure."
|
||||
exit 1
|
||||
fi
|
20
server/serving-api/bin/package.sh
Normal file
20
server/serving-api/bin/package.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#! /bin/bash
|
||||
###########################################
|
||||
#
|
||||
###########################################
|
||||
|
||||
# constants
|
||||
baseDir=$(cd `dirname "$0"`;pwd)
|
||||
cwdDir=$PWD
|
||||
export PYTHONUNBUFFERED=1
|
||||
export PATH=/opt/miniconda3/envs/venv-py3/bin:$PATH
|
||||
export TS=$(date +%Y%m%d%H%M%S)
|
||||
export DATE=`date "+%Y%m%d"`
|
||||
export DATE_WITH_TIME=`date "+%Y%m%d-%H%M%S"` #add %3N as we want millisecond too
|
||||
|
||||
# functions
|
||||
|
||||
# main
|
||||
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
|
||||
cd $baseDir/..
|
||||
mvn -DskipTests clean package
|
@ -25,6 +25,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>serving-api</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -19,4 +19,5 @@ plugins.config.felix.fileinstall.bundles.updateWithListeners=true
|
||||
plugins.config.org.osgi.framework.system.packages.extra=org.osgi.framework,org.xml.sax,org.xml.sax.helpers,javax.xml.parsers,javax.naming
|
||||
plugins.config.auto.exported.packages=com.cskefu.mod.plugin,org.slf4j
|
||||
|
||||
server.port=6500
|
||||
server.servlet.context-path=/api
|
||||
|
Loading…
x
Reference in New Issue
Block a user