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
RUN apt-get -y install netcat
RUN apt-get -y install curl
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
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
ARG API_PORT=9000
EXPOSE ${API_PORT}
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
COPY src ./src
COPY bot.properties.example bot.properties ./
COPY startup.sh ./
RUN ["chmod", "+x", "./mvnw"]
RUN ./mvnw install
COPY --from=build /target/netneutrality-jar-with-dependencies.jar ./
RUN ["chmod", "+x", "./startup.sh"]
CMD ["./startup.sh"]
+1 -1
View File
@@ -2,7 +2,7 @@ version: '3.3'
services:
db:
image: mariadb:10.7
image: mariadb:lts
container_name: db
restart: unless-stopped
volumes:
+8 -8
View File
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
function prop {
prop() {
grep "${1}" bot.properties | cut -d'=' -f2
}
function _term() {
_term() {
echo "Caught SIGTERM/SIGINT signal, graceful shutdown of bot.."
if [ -z "$pid" ]; then
echo "Bot isn't running, exiting."
@@ -16,10 +16,10 @@ function _term() {
fi
}
trap _term SIGTERM
trap _term SIGINT
trap _term TERM
trap _term INT
if [ ! -f /bin/nc ]; then
if [ ! -f /usr/bin/nc ]; then
echo "nc not found. Exiting."
exit 1
fi
@@ -40,9 +40,9 @@ echo "Waiting 10 seconds for database to start.."
sleep 10
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..";
/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=$!
wait "$pid"