public Map<String, String> getPorts() { if (ports == null) { ports = new HashMap<>(); } if (ports.isEmpty()) { ports = findPropertiesWithPrefix(project.getProperties(), "docker.port.container."); } return ports; }
/** * Returns the map of entries in the properties object which have keys starting with the given prefix, removing the prefix * from the returned map. */ public static Map<String, String> findPropertiesWithPrefix(Properties properties, String prefix) { return findPropertiesWithPrefix(properties, prefix, Functions.<String>noop()); }
public Map<String, String> getEnvironmentVariables() { if (environmentVariables == null) { environmentVariables = new HashMap<>(); } if (environmentVariables.isEmpty()) { environmentVariables = new HashMap<>(); Map<String, String> lowerCaseProperties = findPropertiesWithPrefix(project.getProperties(), "docker.env."); Set<Map.Entry<String, String>> entries = lowerCaseProperties.entrySet(); for (Map.Entry<String, String> entry : entries) { String key = entry.getKey(); if (key != null) { environmentVariables.put(key.toUpperCase(), entry.getValue()); } } } if (!environmentVariables.containsKey("SERVICE")) { environmentVariables.put("SERVICE", service); } if (!environmentVariables.containsKey("SERVICE_NAME")) { environmentVariables.put("SERVICE_NAME", serviceName); } return environmentVariables; }