Public Repository

Last pushed: a year ago
Short Description
Short description is empty for this repo.
Full Description

Full description is empty for this repo.

Docker Pull Command
Owner
francescoferrante

Comments (2)
francescoferrante
a year ago

This is the code

public static void main(String[] args) throws IOException {
    Properties properties = new Properties();
    properties.setProperty("line", "%ENVVAR1%_%ENVVAR2%_%ENVVAR3%");
    Enumeration<?> propertyNames = properties.propertyNames();

    Pattern pattern = Pattern.compile("%(\\w+)%");
    while(propertyNames.hasMoreElements()) {
        String propertyName = (String) propertyNames.nextElement();
        Matcher m = pattern.matcher(properties.getProperty(propertyName));
        while(m.find()) {
            String envPropertyName = m.group(1);
            String envPropertyValue = System.getenv(envPropertyName);
            if(envPropertyValue != null) {
                String propertyValue = properties.getProperty(propertyName);
                properties.setProperty(propertyName, propertyValue.replaceFirst("%" + envPropertyName + "%", envPropertyValue));
                System.out.println(properties.getProperty(propertyName));
            } else {
                envPropertyName = envPropertyName + "_UNDEFINED";
            }
        }
    }
}
francescoferrante
a year ago

docker run -e "ENVVAR1=ENVVAR1_VALUE" -e "ENVVAR2=ENVVAR2_VALUE" -e "ENVVAR3=ENVVAR3_VALUE" -p 8080:8080 -t env_settings_from_docker