From 9646236fa8d1f3c842b91a097f76d2f5b74dfecb Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Thu, 13 Aug 2026 09:27:53 -0400 Subject: [PATCH] feat: externalize config via env vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add .env.example with all configurable variables documented (DB URL, HTTP port/host, cookie, JWT issuer/keys, log level) - Remove hardcoded -Dquarkus.http.host from Dockerfile ENTRYPOINT (application.properties already sets the default; env vars can now override it at runtime without conflicting with -D flags) All env vars follow Quarkus's auto-binding convention: property.key → PROPERTY_KEY (uppercase) Most useful for production: - QUARKUS_DATASOURCE_JDBC_URL: DB file path - QUARKUS_HTTP_PORT: HTTP port - QUARKUS_HTTP_HOST: bind interface - APP_AUTH_COOKIE_SECURE: enable Secure flag behind HTTPS - MP_JWT_VERIFY_PUBLICKEY_LOCATION: externalize RSA keys --- .env.example | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6bfa4e6 --- /dev/null +++ b/.env.example @@ -0,0 +1,49 @@ +# shot-crafter-calculator — variables de entorno +# Las variables siguen la convencion de Quarkus: puntos → underscores, mayusculas. +# Cualquier property de src/main/resources/application.properties se puede overridear. +# +# Uso: +# docker run --env-file .env gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest +# docker run -e QUARKUS_HTTP_PORT=9090 gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest + +# ===== HTTP server ===== +# QUARKUS_HTTP_PORT=8080 +# QUARKUS_HTTP_HOST=0.0.0.0 + +# ===== Base de datos ===== +# Default: jdbc:h2:file:./data/shots (queda en /work/data/shots.mv.db dentro del container) +# Produccion tipica (con volumen montado en /work/data): +# QUARKUS_DATASOURCE_JDBC_URL=jdbc:h2:file:/work/data/shots;DB_CLOSE_DELAY=-1 +# Para MySQL/Postgres cambiar tambien db-kind y credenciales: +# QUARKUS_DATASOURCE_DB_KIND=mysql +# QUARKUS_DATASOURCE_JDBC_URL=jdbc:mysql://db:3306/shots +# QUARKUS_DATASOURCE_USERNAME=shot +# QUARKUS_DATASOURCE_PASSWORD=secret +# QUARKUS_HIBERNATE_ORM_DATABASE_GENERATION=update + +# ===== JWT / Auth ===== +# MP_JWT_VERIFY_ISSUER=shot-crafter-calculator +# MP_JWT_VERIFY_PUBLICKEY_LOCATION=publicKey.pem +# SMALLRYE_JWT_SIGN_KEY_LOCATION=privateKey.pem +# Si queres que el container NO bakee las claves, monta los .pem como volumen: +# docker run -v ./keys:/work/keys \ +# -e MP_JWT_VERIFY_PUBLICKEY_LOCATION=/work/keys/publicKey.pem \ +# -e SMALLRYE_JWT_SIGN_KEY_LOCATION=/work/keys/privateKey.pem ... + +# ===== Cookie ===== +# APP_AUTH_COOKIE_NAME=auth-token +# APP_AUTH_COOKIE_MAX_AGE_SECONDS=86400 +# APP_AUTH_COOKIE_SECURE=false # cambiar a true en produccion con HTTPS + +# ===== Logging ===== +# QUARKUS_LOG_LEVEL=INFO +# QUARKUS_LOG_CATEGORY__com_l2_shots=DEBUG + +# ===== Ejemplo de uso con persistencia ===== +# docker run -d \ +# --name shot-crafter \ +# -p 8080:8080 \ +# -v /opt/shot-crafter-data:/work/data \ +# -e QUARKUS_DATASOURCE_JDBC_URL='jdbc:h2:file:/work/data/shots;DB_CLOSE_DELAY=-1' \ +# -e APP_AUTH_COOKIE_SECURE=true \ +# gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cd6fd2b..dbdd94a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,4 @@ RUN chmod 775 /work /work/application \ EXPOSE 8080 USER 1001 -ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] +ENTRYPOINT ["./application"]