FROM eclipse-temurin:17-jdk-alpine as build

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 bot.properties.example bot.properties ./
COPY startup.sh ./
COPY --from=build /target/netneutrality-jar-with-dependencies.jar ./

RUN ["chmod", "+x", "./startup.sh"]
CMD ["./startup.sh"]