Skip to content

Commit 362525b

Browse files
authored
Merge pull request #42 from axiom-data-science/env-variables
Allow setup.xml configuration via ENV variables
2 parents f84b8d2 + c27b67d commit 362525b

File tree

4 files changed

+130
-498
lines changed

4 files changed

+130
-498
lines changed

Dockerfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LABEL maintainer="Kyle Wilcox <[email protected]>"
44
ENV ERDDAP_VERSION 2.14
55
ENV ERDDAP_CONTENT_URL https://github.com/BobSimons/erddap/releases/download/v$ERDDAP_VERSION/erddapContent.zip
66
ENV ERDDAP_WAR_URL https://github.com/BobSimons/erddap/releases/download/v$ERDDAP_VERSION/erddap.war
7-
ENV ERDDAP_DATA /erddapData
7+
ENV ERDDAP_bigParentDirectory /erddapData
88

99
RUN \
1010
curl -fSL "${ERDDAP_CONTENT_URL}" -o /erddapContent.zip && \
@@ -15,13 +15,33 @@ RUN \
1515
rm /erddap.war && \
1616
sed -i 's#</Context>#<Resources cachingAllowed="true" cacheMaxSize="100000" />\n&#' ${CATALINA_HOME}/conf/context.xml && \
1717
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
18-
mkdir -p ${ERDDAP_DATA}
18+
mkdir -p ${ERDDAP_bigParentDirectory}
1919

2020
# Java options
2121
COPY files/setenv.sh ${CATALINA_HOME}/bin/setenv.sh
2222

23-
# ERDDAP setup.xml
24-
COPY files/setup.xml ${CATALINA_HOME}/content/erddap/setup.xml
23+
# Default configuration
24+
ENV ERDDAP_baseHttpsUrl="https://localhost:8443" \
25+
ERDDAP_flagKeyKey="73976bb0-9cd4-11e3-a5e2-0800200c9a66" \
26+
ERDDAP_emailEverythingTo="[email protected]" \
27+
ERDDAP_emailDailyReportsTo="[email protected]" \
28+
ERDDAP_emailFromAddress="[email protected]" \
29+
ERDDAP_emailUserName="" \
30+
ERDDAP_emailPassword="" \
31+
ERDDAP_emailProperties="" \
32+
ERDDAP_emailSmtpHost="" \
33+
ERDDAP_emailSmtpPort="" \
34+
ERDDAP_adminInstitution="Axiom Docker Install" \
35+
ERDDAP_adminInstitutionUrl="https://github.com/axiom-data-science/docker-erddap" \
36+
ERDDAP_adminIndividualName="Axiom Docker Install" \
37+
ERDDAP_adminPosition="Software Engineer" \
38+
ERDDAP_adminPhone="555-555-5555" \
39+
ERDDAP_adminAddress="123 Irrelevant St." \
40+
ERDDAP_adminCity="Nowhere" \
41+
ERDDAP_adminStateOrProvince="AK" \
42+
ERDDAP_adminPostalCode="99504" \
43+
ERDDAP_adminCountry="USA" \
44+
ERDDAP_adminEmail="[email protected]"
2545

2646
COPY entrypoint.sh /
2747
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ See [these instructions for configuring Tomcat](https://github.com/unidata/tomca
5050

5151
### ERDDAP
5252

53+
Any number of these options can be taken to configure your ERDDAP container instance to your liking.
54+
5355
1. Mount your own `content/erddap` directory:
5456

5557
```bash
5658
$ docker run \
59+
-p 8080:8080 \
5760
-v /path/to/your/erddap/directory:/usr/local/tomcat/content/erddap \
5861
... \
5962
axiom/docker-erddap
@@ -65,19 +68,106 @@ See [these instructions for configuring Tomcat](https://github.com/unidata/tomca
6568

6669
```bash
6770
$ docker run \
71+
-p 8080:8080 \
6872
-v /path/to/your/setup.xml:/usr/local/tomcat/content/erddap/setup.xml \
6973
-v /path/to/your/datasets.xml:/usr/local/tomcat/content/erddap/datasets.xml \
7074
... \
7175
axiom/docker-erddap
7276
```
7377

74-
**Any custom setup.xml needs to specify `<bigParentDirectory>/erddapData/</bigParentDirectory>`**
78+
**If you mount setup.xml file make sure to set `<bigParentDirectory>/erddapData/</bigParentDirectory>`**
79+
80+
2. Configure using environmental variables
81+
82+
You can set environmental variables to configure ERDDAP's `setup.xml` since version 2.14. See the [ERDDAP documentation](https://coastwatch.pfeg.noaa.gov/erddap/download/setup.html#setupEnvironmentVariables) for details. This can be very useful so you don't need to mount a custom `setup.xml` file into your container. If taking this approach you should look into setting the following ERDDAP config options:
83+
84+
* `ERDDAP_baseURL`
85+
* `ERDDAP_baseHttpsUrl`
86+
* `ERDDAP_flagKeyKey`
87+
* `ERDDAP_emailEverythingTo`
88+
* `ERDDAP_emailFromAddress`
89+
* `ERDDAP_emailUserName`
90+
* `ERDDAP_emailPassword`
91+
* `ERDDAP_emailSmtpHost`
92+
* `ERDDAP_emailSmtpPort`
93+
* `ERDDAP_adminInstitution`
94+
* `ERDDAP_adminInstitutionUrl`
95+
* `ERDDAP_adminIndividualName`
96+
* `ERDDAP_adminPosition`
97+
* `ERDDAP_adminPhone`
98+
* `ERDDAP_adminAddress`
99+
* `ERDDAP_adminCity`
100+
* `ERDDAP_adminStateOrProvince`
101+
* `ERDDAP_adminPostalCode`
102+
* `ERDDAP_adminCountry`
103+
* `ERDDAP_adminEmail`
104+
105+
For example:
106+
107+
```bash
108+
docker run \
109+
-p 8080:8080 \
110+
-e ERDDAP_baseURL="http://localhost:8080" \
111+
-e ERDDAP_adminEmail="[email protected]" \
112+
axiom/docker-erddap
113+
```
114+
115+
**Depending on your container environment, it may pass in it's own environment variables relating to your resources. Potentially there could be a collision with the `ERDDAP_*` config variables if any of your resources start with ERDDAP.**
75116
117+
3. Configure using a shell script
76118
77-
2. Mount your own `bigParentDirectory`:
119+
You can mount a file called `config.sh` to `${CATALINA_HOME}/bin/config.sh` that sets any ERDDAP configuration environmental variables you want to use. This is sourced in the container-provided `setenv.sh` file and and all variables will be exported to be used by ERDDAP for configuration. These will take precedence over environmental variable specified when running the container (see above).
78120
79121
```bash
80122
$ docker run \
123+
-p 8080:8080 \
124+
-e ERDDAP_adminEmail="[email protected]" \
125+
-v /path/to/your/config.sh:/usr/local/tomcat/bin/config.sh \
126+
... \
127+
axiom/docker-erddap
128+
```
129+
130+
where `config.sh` contains any of the ERDDAP environmental configuration variables:
131+
132+
```sh
133+
ERDDAP_adminEmail="[email protected]"
134+
```
135+
136+
You can set any number of configuration variables in the config.sh.
137+
138+
```bash
139+
ERDDAP_bigParentDirectory="/erddapData/"
140+
ERDDAP_baseUrl="http://localhost:8080"
141+
ERDDAP_baseHttpsUrl="https://localhost:8443"
142+
ERDDAP_flagKeyKey="73976bb0-9cd4-11e3-a5e2-0800200c9a66"
143+
144+
ERDDAP_emailEverythingTo="[email protected]"
145+
ERDDAP_emailDailyReportsTo="[email protected]"
146+
ERDDAP_emailFromAddress="[email protected]"
147+
ERDDAP_emailUserName=""
148+
ERDDAP_emailPassword=""
149+
ERDDAP_emailProperties=""
150+
ERDDAP_emailSmtpHost=""
151+
ERDDAP_emailSmtpPort=""
152+
153+
ERDDAP_adminInstitution="Axiom Docker Install"
154+
ERDDAP_adminInstitutionUrl="https://github.com/axiom-data-science/docker-erddap"
155+
ERDDAP_adminIndividualName="Axiom Docker Install"
156+
ERDDAP_adminPosition="Software Engineer"
157+
ERDDAP_adminPhone="555-555-5555"
158+
ERDDAP_adminAddress="123 Irrelevant St."
159+
ERDDAP_adminCity="Nowhere"
160+
ERDDAP_adminStateOrProvince="AK"
161+
ERDDAP_adminPostalCode="99504"
162+
ERDDAP_adminCountry="USA"
163+
ERDDAP_adminEmail="[email protected]"
164+
```
165+
166+
4. Mount your own `bigParentDirectory`:
167+
168+
```bash
169+
$ docker run \
170+
-p 8080:8080 \
81171
-v /path/to/your/erddap/bigParentDirectory:/erddapData \
82172
... \
83173
axiom/docker-erddap
@@ -86,11 +176,11 @@ See [these instructions for configuring Tomcat](https://github.com/unidata/tomca
86176
This is **highly** recommended, or nothing will persist across container restarts (logs/cache/etc.)
87177
88178
89-
3. Specify the amount of memory to be allocated:
179+
5. Specify the amount of memory to be allocated:
90180
91181
``` bash
92-
93182
$ docker run \
183+
-p 8080:8080 \
94184
--env ERDDAP_MIN_MEMORY=4G --env ERDDAP_MAX_MEMORY=8G
95185
... \
96186
axiom/docker-erddap

files/setenv.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/bin/sh
22

3+
if [ -f "${CATALINA_HOME}/bin/config.sh" ];
4+
then
5+
set -o allexport
6+
source "${CATALINA_HOME}/bin/config.sh"
7+
set +o allexport
8+
fi
9+
10+
ERDDAP_CONFIG=$(env | grep --regexp "^ERDDAP_.*$" | sort)
11+
if [ -n "$ERDDAP_CONFIG" ]; then
12+
echo "ERDDAP configured with: $ERDDAP_CONFIG"
13+
fi
14+
315
# JAVA_OPTS
416
MEMORY="${ERDDAP_MEMORY:-4G}"
517
NORMAL="-server -d64 -Xms${ERDDAP_MIN_MEMORY:-${MEMORY}} -Xmx${ERDDAP_MAX_MEMORY:-${MEMORY}}"

0 commit comments

Comments
 (0)