Compare commits

..
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -20,11 +20,12 @@ RUN chmod +x gradlew && ./gradlew :backend:bootJar --no-daemon -x test
# 3. Runtime: not root; data in /app/data (volume) # 3. Runtime: not root; data in /app/data (volume)
FROM eclipse-temurin:21-jre-alpine FROM eclipse-temurin:21-jre-alpine
RUN apk add --no-cache curl && addgroup -S mail && adduser -S -G mail mail \ # own user: "mail" already exists in Alpine (uid 8, group 12) — addgroup mail fails
&& mkdir -p /app/data/attachments /app/data/dkim-keys && chown -R mail:mail /app/data RUN apk add --no-cache curl && addgroup -S -g 10001 app && adduser -S -u 10001 -G app app \
&& mkdir -p /app/data/attachments /app/data/dkim-keys && chown -R app:app /app/data
WORKDIR /app WORKDIR /app
COPY --from=build /app/backend/build/libs/*.jar app.jar COPY --from=build /app/backend/build/libs/*.jar app.jar
USER mail USER app
ENV MAIL_ATTACHMENTS_DIR=/app/data/attachments DKIM_KEYS_DIR=/app/data/dkim-keys ENV MAIL_ATTACHMENTS_DIR=/app/data/attachments DKIM_KEYS_DIR=/app/data/dkim-keys
EXPOSE 8080 3025 EXPOSE 8080 3025
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
+1 -1
View File
@@ -17,7 +17,7 @@ services:
for name in DB_PASSWORD JWT_SECRET; do for name in DB_PASSWORD JWT_SECRET; do
[ -s /secrets/$$name ] || head -c 48 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' > /secrets/$$name [ -s /secrets/$$name ] || head -c 48 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' > /secrets/$$name
done done
# postgres reads it as uid 70, the app as "mail" — readable inside these containers only # postgres reads it as uid 70, the app as uid 10001 — readable inside these containers only
chmod 644 /secrets/DB_PASSWORD /secrets/JWT_SECRET chmod 644 /secrets/DB_PASSWORD /secrets/JWT_SECRET
volumes: volumes:
- secrets:/secrets - secrets:/secrets