Compare commits

...

2 Commits

Author SHA1 Message Date
afcbcbaf12 .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-12 13:14:53 +02:00
e97864a251 Docker 2025-09-12 13:10:48 +02:00
3 changed files with 75 additions and 0 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
target/
.git/
.gitignore
.idea/
.vscode/
**/*.iml
secrets/
.env

29
.drone.yml Normal file
View File

@ -0,0 +1,29 @@
kind: pipeline
type: docker
name: default
steps:
- name: debug registry secrets
image: alpine
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
TEST:
from_secret: test
commands:
- echo $TEST
- echo $USERNAME
- echo $PASSWORD
- name: build and push electricityalert image
image: plugins/docker
settings:
repo: rubble.se:5000/urmo/electricityalert
registry: rubble.se:5000
tags: latest
username:
from_secret: docker_username
password:
from_secret: docker_password

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
# -------- Build stage --------
FROM maven:3.9.9-eclipse-temurin-21 AS build
WORKDIR /app
# Cache dependencies
COPY pom.xml .
RUN mvn -q -DskipTests dependency:go-offline
# Build
COPY src ./src
RUN mvn -q -DskipTests package
# -------- Runtime stage --------
FROM eclipse-temurin:21-jre-jammy
# Timezone & JVM defaults
ENV TZ=Europe/Stockholm
# Ensure JVM uses Stockholm time regardless of container TZ config
ENV JAVA_TOOL_OPTIONS="-Duser.timezone=Europe/Stockholm"
# Sensible container-aware memory settings (tweak as you like)
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75"
# Non-root user
RUN useradd -ms /bin/bash spring
WORKDIR /app
COPY --from=build /app/target/electricityalert-*.jar /app/app.jar
RUN chown -R spring:spring /app
USER spring
# App port
EXPOSE 8080
# Spring profile can be overridden at runtime: -e SPRING_PROFILES_ACTIVE=prod
ENV SPRING_PROFILES_ACTIVE=prod
# Pass secrets as env vars (see your application.properties)
# -e TELEGRAM_BOT_TOKEN=... -e TELEGRAM_CHAT_ID=... -e GRAPHQL_ACCESS_TOKEN=...
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /app/app.jar"]