Skip to content

EightAugusto/spring-cloud-config-server-example

Repository files navigation

Spring Cloud Config Server

Spring Cloud Config Server example providing configuration from Spring Cloud Config Server Example Properties.


Requirements

  • Docker 26.1.4
  • Make 3.81
  • Java 21
  • Maven3.9.7

Run in Git mode

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;

Run in Native mode

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;

Stop in Docker

make docker.stop

Encrypt

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};