https://github.com/rozidan/docker-secret-spring-boot-starter
A Spring Boot launcher that allows you to read the contents of Docker containers secrets into your Spring Boot application
https://github.com/rozidan/docker-secret-spring-boot-starter
docker docker-secrets java spring-autoconfigurations spring-boot spring-property
Last synced: 6 months ago
JSON representation
A Spring Boot launcher that allows you to read the contents of Docker containers secrets into your Spring Boot application
- Host: GitHub
- URL: https://github.com/rozidan/docker-secret-spring-boot-starter
- Owner: rozidan
- License: apache-2.0
- Created: 2021-02-16T12:30:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-24T14:35:56.000Z (over 5 years ago)
- Last Synced: 2024-12-16T08:37:19.254Z (over 1 year ago)
- Topics: docker, docker-secrets, java, spring-autoconfigurations, spring-boot, spring-property
- Language: Java
- Homepage:
- Size: 76.2 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot Docker Secret Starter
> A Spring Boot launcher that allows you to read the contents of Docker containers secrets into your Spring Boot application.
[](https://travis-ci.org/rozidan/docker-secret-spring-boot-starter)
[](https://coveralls.io/github/rozidan/docker-secret-spring-boot-starter?branch=master)
[](https://maven-badges.herokuapp.com/maven-central/com.github.rozidan/docker-secret-spring-boot-starter/)
[](https://oss.sonatype.org/content/repositories/snapshots/com/github/rozidan/docker-secret-spring-boot-starter/)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
## Features
Register the docker-secret starter to your Spring Boot application and reads docker container secrets content to spring properties before it is starting up
## Setup
In order to add docker-secret to your project simply add this dependency to your classpath:
```xml
com.github.rozidan
docker-secret-spring-boot-starter
1.0.0
```
```groovy
compile 'com.github.rozidan:docker-secret-spring-boot-starter:1.0.0'
```
For snapshots versions add the sonatype public repository:
```groovy
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/groups/public" }
...
}
```
### How does it work?
According to the file names, the docker-secrets starter reads the secrets before the application starts up and adds/overrides spring properties with their content.
For example, if there is a secret called "spring.my.prop", the property "my.prop" will be added or overrode, and its content will be the secret file content
### Which secrets are going to be Spring property?
There are two different prefixes for secrets that will convert to Spring properties:
* "spring.*" - the property content will be exactly as secret content.
* "spring64.*" - the property content will be base64 decoded.
### From which folder will include the extraction of the secrets?
The property/env called "secrets.path" allocates folder path.
Example for classpath folder:
```shell
secrets.path=classpath:/secretstests/*
```
Example for system folder:
```shell
secrets.path=file:/run/secrets/*
```
> **NOTE:** The default path for Docker secrets is "/run/secrets/*",
> and it is the default path in case 'secrets.path' is not defined
### The property source
A new property source (PropertiesPropertySource) will be created with a name as follows:
```text
"Container secrets converted to properties via location '[the path of the secrets]' with '[full class name of the EnvironmentPostProcessor]'"
```
and this is how it will showed with the actuator endpoints.
### Docker container configuration
Example for a secret config within Docker compose:
```yaml
secrets:
- source: database-pass
target: spring.my.database.pass
```
## License
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)