docker镜像构建

This commit is contained in:
william
2024-04-27 08:46:05 +08:00
parent 40555fcd64
commit 7524952c46
3 changed files with 55 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
stages:
# 构建
- build
- docker
- webhook
build:
@@ -37,6 +38,26 @@ build:
- mvn clean install -Dmaven.test.skip=true
- ls
- echo ">>>>>>Finish Building<<<<<<"
docker:
stage: docker
tags:
- hk2
dependencies:
- build
only:
- main
- develop
script:
- echo ">>>>>>Start Building Image<<<<<<"
- ls
- ls target
- echo $DOCKER_PASSWORD
- echo $CI_PIPELINE_ID
- docker build -t juyoutech/india_market_java:latest .
- docker tag juyoutech/india_market_java:latest juyoutech/india_market_java:$CI_PIPELINE_ID
- docker login -u juyoutech -p $DOCKER_PASSWORD
- docker push juyoutech/india_market_java:latest
- docker push juyoutech/india_market_java:$CI_PIPELINE_ID
webhook:
stage: webhook
only:

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM openjdk:8
RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \
&& echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list \
&& echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/10no-check-valid
RUN apt-get update
#RUN apt-get install -y iputils-ping dnsutils vim net-tools --allow-unauthenticated
WORKDIR /app
COPY target/india_market_java.jar /app/app.jar
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
CMD ["docker-entrypoint.sh"]

17
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
export JAVA_OPTS="$JAVA_OPTS -XX:-OmitStackTraceInFastThrow \
-Ddb.url='jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DB?useUnicode=true&autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=false' \
-Ddb.username=$MYSQL_USER \
-Ddb.password=$MYSQL_PASSWORD \
-Dredis.ip=$REDIS_HOST \
-Dredis.port=$REDIS_PORT \
-Dredis.pwd=$REDIS_PASSWORD \
-Denable.scheduled=false"
echo 'param:'$@
echo 'JAVA_OPTS:'$JAVA_OPTS
java $JAVA_OPTS -jar /app/app.jar $@
tail -f /dev/null