Commit 8bdee67e authored by LAVENIER's avatar LAVENIER
Browse files

[fix] CI: fix yaml

parent 3ce4a7a9
......@@ -236,45 +236,15 @@ gitlab-release:
script:
# Create the target directory
- mkdir -p target/docker/config
- cp -rf ${APP_WAR_MODULE}/src/main/docker/* target/docker/
- cp -f ${ARTIFACT_WAR_FILE} target/docker/app.war
- cp -f ${ARTIFACT_CONFIG_FILES} target/docker/config/
- ls -l target/docker/config
- cd target/docker
# Create the starter script
# - echo '#!/bin/bash' > app.sh
# - echo 'BASEDIR=/app' >> app.sh
# - echo 'JAVA_OPTS="-Dsumaris.basedir=${BASEDIR}"' >> app.sh
# - echo 'JAVA_OPTS="$JAVA_OPTS -Dspring.config.location=${BASEDIR}/config/"' >> app.sh
# - echo 'JAVA_OPTS="$JAVA_OPTS -Doracle.net.tns_admin=/home/tnsnames' >> app.sh
# - echo 'JAVA_OPTS="$JAVA_OPTS -Doracle.jdbc.timezoneAsRegion=false"' >> app.sh
# - echo '[[ "_${PROFILES}" != "_" ]] && JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=${PROFILES}"' >> app.sh
# - echo '[[ "_${TZ}" != "_" ]] && JAVA_OPTS="$JAVA_OPTS -Duser.timezone=${TZ}"' >> app.sh
# - echo '[[ "_${PORT}" != "_" ]] && JAVA_OPTS="$JAVA_OPTS -Dserver.port=${PORT}"' >> app.sh
# - echo 'ARGS=${@:2}' >> app.sh
# - echo 'java ${JAVA_OPTS} -server -jar ${BASEDIR}/app.war ${ARGS}' >> app.sh
# # Create the Dockerfile
# - echo 'FROM openjdk:11-jre' > Dockerfile
# - echo "ARG WAR_FILE=app.war" >> Dockerfile
# - echo "ARG CONFIG_FILES=config/*.properties" >> Dockerfile
# - echo 'RUN apt-get update && apt-get -y install libsodium-dev' >> Dockerfile
# - echo 'RUN addgroup -S spring && adduser -S spring -G spring' >> Dockerfile
# - echo 'USER spring:spring' >> Dockerfile
# - echo 'WORKDIR /app' >> Dockerfile
# - echo 'COPY app.sh app.sh' >> Dockerfile
# - echo 'RUN chmod +x app.sh' >> Dockerfile
# - echo 'COPY ${WAR_FILE} app.war' >> Dockerfile
# - echo 'RUN mkdir config' >> Dockerfile
# - echo 'COPY ${CONFIG_FILES} ./config/' >> Dockerfile
# - echo 'ENV PORT=8080 \' >> Dockerfile
# - echo ' TZ=UTC \' >> Dockerfile
# - echo ' PROFILES=default' >> Dockerfile
# - echo 'EXPOSE ${PORT}' >> Dockerfile
# - echo 'ENTRYPOINT ["app.sh"]' >> Dockerfile
- cp -rf ${APP_WAR_MODULE}/src/main/docker/* .
- cp -f ${ARTIFACT_WAR_FILE} app.war
- cp -f ${ARTIFACT_CONFIG_FILES} ./config/
- ls -l ./config
# Build docker image
#- docker pull ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} || true
#- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- docker build --no-cache -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- docker pull ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
#- docker build --no-cache -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- docker push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
artifacts:
paths:
......
FROM openjdk:8-jdk
ARG ENTRYPOINT=app.sh
ARG WAR_FILE=app.war
ARG CONFIG_FILES=config/*.properties
RUN apt update && apt -y install libsodium-dev
#RUN addgroup -S spring && adduser -S spring -G spring
#USER spring:spring
WORKDIR /app
COPY app.sh app.sh
RUN chmod +x app.sh
COPY ${WAR_FILE} app.war
COPY ${CONFIG_FILES} config/
COPY ${ENTRYPOINT} /app/app.sh
RUN chmod +x /app/app.sh
COPY ${WAR_FILE} /app/app.war
COPY ${CONFIG_FILES} /app/config/
ENV PORT=8080 \
TZ=UTC \
PROFILES=default
WORKDIR /app
EXPOSE ${PORT}
ENTRYPOINT ["app.sh"]
\ No newline at end of file
FROM openjdk:8-jdk-alpine
ARG WAR_FILE=app.war
ARG CONFIG_FILES=config/*.properties
RUN apk update && apk install libsodium-dev
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
WORKDIR /app
COPY app.sh app.sh
RUN chmod +x app.sh
COPY ${WAR_FILE} app.war
COPY ${CONFIG_FILES} config/
ENV PORT=8080 \
TZ=UTC \
PROFILES=default
EXPOSE ${PORT}
ENTRYPOINT ["app.sh"]
\ No newline at end of file
#!/bin/bash
SCRIPT_DIR=$(dirname $0)
BASEDIR=$(cd "${SCRIPT_DIR}" && pwd -P)
BASEDIR=/app
JAVA_OPTS="-Dsumaris.basedir=${BASEDIR}"
JAVA_OPTS="$JAVA_OPTS -Dspring.config.location=${BASEDIR}/config/"
JAVA_OPTS="$JAVA_OPTS -Doracle.net.tns_admin=/home/tnsnames"
JAVA_OPTS="$JAVA_OPTS -Doracle.jdbc.timezoneAsRegion=false"
[[ "_${PROFILES}" != "_" ]] && JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=${PROFILES}"
[[ "_${TZ}" != "_" ]] && JAVA_OPTS="$JAVA_OPTS -Duser.timezone=${TZ}"
[[ "_${PORT}" -ne "_" ]] && JAVA_OPTS="$JAVA_OPTS -Dserver.port=${PORT}"
ARGS=${@:2}
JAVA_CMD="java ${JAVA_OPTS} -server -jar ${BASEDIR}/app.war ${ARGS}"
JAVA_OPTS="${JAVA_OPTS} -Dspring.config.location=${BASEDIR}/config/"
JAVA_OPTS="${JAVA_OPTS} -Doracle.net.tns_admin=/home/tnsnames"
JAVA_OPTS="${JAVA_OPTS} -Doracle.jdbc.timezoneAsRegion=false"
[[ "_${PROFILES}" != "_" ]] && JAVA_OPTS="${JAVA_OPTS} -Dspring.profiles.active=${PROFILES}"
[[ "_${TZ}" != "_" ]] && JAVA_OPTS="${JAVA_OPTS} -Duser.timezone=${TZ}"
[[ "_${PORT}" != "_" ]] && JAVA_OPTS="${JAVA_OPTS} -Dserver.port=${PORT}"
ARGS=
# TODO test this
#ARGS=${@:2}
echo "*** Starting Application - args: ${ARGS} - profiles: ${PROFILES} ***"
echo "Starting, with arguments: ${ARGS} - profiles: ${PROFILES}"
echo " > ${CMD}"
${JAVA_CMD}
\ No newline at end of file
java ${JAVA_OPTS} -server -jar ${BASEDIR}/app.war ${ARGS}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment