https://github.com/moberwasserlechner/docker-secret-spring-post-processor
Use docker secrets in a spring boot application with ease
https://github.com/moberwasserlechner/docker-secret-spring-post-processor
docker docker-compose docker-secrets spring-boot
Last synced: 4 months ago
JSON representation
Use docker secrets in a spring boot application with ease
- Host: GitHub
- URL: https://github.com/moberwasserlechner/docker-secret-spring-post-processor
- Owner: moberwasserlechner
- License: mit
- Created: 2020-02-19T11:31:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-18T22:40:26.000Z (about 5 years ago)
- Last Synced: 2025-11-23T14:03:59.368Z (7 months ago)
- Topics: docker, docker-compose, docker-secrets, spring-boot
- Language: Java
- Homepage:
- Size: 104 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot PostProcessor for Docker Secrets
[](https://search.maven.org/search?q=g:%22com.byteowls%22%20AND%20a:%22docker-secret-spring-post-processor%22)

[](https://www.paypal.me/moberwasserlechner)
Docker secrets are mounted to the container on a file basis. This is an approach not support by Spring out of the box.
The class `DockerSecretEnvPostProcessor` reads these secret files and creates properties usable like any other spring property.
```properties
# `docker_secret_` is the prefix and `email_username` the name of the secret file
app.email.username=${docker_secret_email_username}
```
## Setup
To enable this post processor you have to create `src/main/resources/META-INF/spring.factories` containing
```
org.springframework.boot.env.EnvironmentPostProcessor=com.byteowls.docker.boot.DockerSecretEnvPostProcessor
```
## Configure
After that you can configure the post processor from your `application-.properties` or any other Spring supported mechanism.
```properties
#key=default_value
# enable/disable the post processor during runtime
docker.boot.secret.enabled=true
# docker secret mount path
docker.boot.secret.path=/run/secrets
# prefix for secret name
docker.boot.secret.prefix=docker_secret_
# remove leading and trailing whitespace chars
docker.boot.secret.trim=true
# print errors to System.out
docker.boot.secret.print.errors=true
# Attention: print all found secrets (masked) to System.out. Use with care.
docker.boot.secret.print.secrets=false
# Attention: unmasks all printed secrets. Use with care.
docker.boot.secret.print.secrets.unmasked=false
```
Note: We print to System.out because the log system is **not ready**, when the post processor is executed.
## Dependency
Maven
```xml
com.byteowls
docker-secret-spring-post-processor
replace.with.version
```
Gradle
```gradle
dependencies {
implementation "com.byteowls:docker-secret-spring-post-processor:REPLACE.WITH.VERSION"
}
```
## Contribute
See [Contribution Guidelines](https://github.com/moberwasserlechner/docker-secret-spring-post-processor/blob/master/.github/CONTRIBUTING.md).
## Gradle
```
./gradlew wrapper --gradle-version 6.8.3
```
## Changelog
See [CHANGELOG](https://github.com/moberwasserlechner/docker-secret-spring-post-processor/blob/master/CHANGELOG.md).
## License
MIT. Please see [LICENSE](https://github.com/moberwasserlechner/docker-secret-spring-post-processor/blob/master/LICENSE).
## BYTEOWLS Software & Consulting
This plugin is powered by [BYTEOWLS Software & Consulting](https://byteowls.com).
If you need extended support for this project like critical changes or releases ahead of schedule. Feel free to contact us for a consulting offer.