Spring Cloud Config Server example providing configuration from Spring Cloud Config Server Example Properties.
- Docker 26.1.4
- Make 3.81
- Java 21
- Maven3.9.7
source .env; \
mvn clean install; \
java \
-Dspring.profiles.active=git \
-Dserver.port=${APPLICATION_PORT} \
-Dencrypt.key=${SPRING_CLOUD_CONFIG_PROPERTIES_ENCRYPT_KEY} \
-Dspring.cloud.config.server.git.uri=${SPRING_CLOUD_CONFIG_PROPERTIES_REPOSITORY} \
-Dspring.cloud.config.server.git.default-label=${SPRING_CLOUD_CONFIG_PROPERTIES_REPOSITORY_LABEL} \
-Dspring.cloud.config.server.git.search-paths=${SPRING_CLOUD_CONFIG_PROPERTIES_REPOSITORY_SEARCH_PATH}/{application} \
-Dspring.cloud.config.server.git.force-pull=true \
-Dspring.cloud.config.server.git.clone-on-start=true \
-jar target/${APPLICATION}.jar;
or
sed -i '' -e "s/^[#]*\s*APPLICATION_PROFILE=.*/APPLICATION_PROFILE=git/" .env; \
mvn clean install; \
make docker.start;
source .env; \
mvn clean install; \
java \
-Dspring.profiles.active=native \
-Dserver.port=${APPLICATION_PORT} \
-Dencrypt.key=${SPRING_CLOUD_CONFIG_PROPERTIES_ENCRYPT_KEY} \
-Dspring.cloud.config.server.native.searchLocations=file://$(pwd)/${SPRING_CLOUD_CONFIG_PROPERTIES_REPOSITORY_SEARCH_PATH}/{application} \
-jar target/${APPLICATION}.jar;
or
sed -i '' -e "s/^[#]*\s*APPLICATION_PROFILE=.*/APPLICATION_PROFILE=native/" .env; \
mvn clean install; \
make docker.start;
make docker.stop
To encrypt a value you can use the following (Replacing ... with your value to be encrypted):
source .env; \
ENCRYPTED_VALUE=$(curl --location --request POST "localhost:${APPLICATION_PORT}/encrypt" \
--header 'Content-Type: text/plain' \
--data-raw EightAugusto); \
echo ${ENCRYPTED_VALUE};
To decrypt a value you can use the following (Replacing ... with your value to be encrypted):
source .env; \
DECRYPTED_VALUE=$(curl --location --request POST "localhost:${APPLICATION_PORT}/decrypt" \
--header 'Content-Type: text/plain' \
--data-raw ${ENCRYPTED_VALUE}); \
echo ${DECRYPTED_VALUE};