Update docker build process

This commit is contained in:
anthorob committed 2024-05-09 15:34:41 -04:00
1 parent f79ab8984a
commit fa93bf6af4
3 files changed
+24 -19

No files matched your search

+15 -10
View File
@@ -1,22 +1,27 @@
FROM openjdk:17-jdk-slim FROM eclipse-temurin:17-jdk-alpine as build
RUN apt-get -y update COPY .mvn/ .mvn
RUN apt-get -y install netcat COPY mvnw pom.xml ./
RUN apt-get -y install curl COPY src ./src
COPY bot.properties.example bot.properties ./
RUN ["chmod", "+x", "./mvnw"]
RUN ./mvnw install
FROM eclipse-temurin:17-jre-alpine
RUN apk add netcat-openbsd
RUN apk add curl
WORKDIR /app WORKDIR /app
ARG API_PORT=9000 ARG API_PORT=9000
EXPOSE ${API_PORT} EXPOSE ${API_PORT}
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
COPY src ./src
COPY bot.properties.example bot.properties ./ COPY bot.properties.example bot.properties ./
COPY startup.sh ./ COPY startup.sh ./
COPY --from=build /target/netneutrality-jar-with-dependencies.jar ./
RUN ["chmod", "+x", "./mvnw"]
RUN ./mvnw install
RUN ["chmod", "+x", "./startup.sh"] RUN ["chmod", "+x", "./startup.sh"]
CMD ["./startup.sh"] CMD ["./startup.sh"]
+1 -1
View File
@@ -2,7 +2,7 @@ version: '3.3'
services: services:
db: db:
image: mariadb:10.7 image: mariadb:lts
container_name: db container_name: db
restart: unless-stopped restart: unless-stopped
volumes: volumes:
+8 -8
View File
@@ -1,10 +1,10 @@
#!/bin/bash #!/bin/sh
function prop { prop() {
grep "${1}" bot.properties | cut -d'=' -f2 grep "${1}" bot.properties | cut -d'=' -f2
} }
function _term() { _term() {
echo "Caught SIGTERM/SIGINT signal, graceful shutdown of bot.." echo "Caught SIGTERM/SIGINT signal, graceful shutdown of bot.."
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
echo "Bot isn't running, exiting." echo "Bot isn't running, exiting."
@@ -16,10 +16,10 @@ function _term() {
fi fi
} }
trap _term SIGTERM trap _term TERM
trap _term SIGINT trap _term INT
if [ ! -f /bin/nc ]; then if [ ! -f /usr/bin/nc ]; then
echo "nc not found. Exiting." echo "nc not found. Exiting."
exit 1 exit 1
fi fi
@@ -40,9 +40,9 @@ echo "Waiting 10 seconds for database to start.."
sleep 10 sleep 10
echo "Checking if MySQL / MariaDB is started.." echo "Checking if MySQL / MariaDB is started.."
if /bin/nc -z "$MYSQL_HOST" "$MYSQL_PORT"; then if /usr/bin/nc -z "$MYSQL_HOST" "$MYSQL_PORT"; then
echo "Database OK. Starting bot.."; echo "Database OK. Starting bot..";
/usr/local/openjdk-17/bin/java -jar target/netneutrality-jar-with-dependencies.jar & /opt/java/openjdk/bin/java -jar /app/netneutrality-jar-with-dependencies.jar &
pid=$! pid=$!
wait "$pid" wait "$pid"