Parcourir la source

docker: set volumes

Zhang Cheng il y a 8 ans
Parent
commit
8ad1cb7fac
3 fichiers modifiés avec 13 ajouts et 3 suppressions
  1. 2 1
      Dockerfile
  2. 5 0
      docker-compose.yml
  3. 6 2
      docker-entry.sh

+ 2 - 1
Dockerfile

@@ -60,7 +60,8 @@ RUN apk add --no-cache mysql-client
 COPY --from=builder /DWSurvey/target/diaowen.war /diaowen.war
 COPY docker-entry.sh /docker-entry.sh
 
-# TODO set volumes
+# TODO this is a dirty hack
+VOLUME ["/dwsurvey/WEB-INF/wjHtml", "/dwsurvey/WEB-INF/classes/conf/site"]
 
 EXPOSE 8080
 

+ 5 - 0
docker-compose.yml

@@ -15,6 +15,9 @@ services:
   dwsurvey:
     image: dwsurvey
     restart: always
+    volumes:
+      - "dwsurvey-wjHtml:/dwsurvey/WEB-INF/wjHtml"
+      - "dwsurvey-site:/dwsurvey/WEB-INF/classes/conf/site"
     links:
       - db
     environment:
@@ -30,3 +33,5 @@ services:
 
 volumes:
   mysql-data: {}
+  dwsurvey-wjHtml: {}
+  dwsurvey-site: {}

+ 6 - 2
docker-entry.sh

@@ -2,6 +2,7 @@
 set -e
 
 WAR_FILE=/diaowen.war
+UNPACK_DIR=/dwsurvey
 WEBAPP_BASE=$CATALINA_HOME/webapps
 
 # determine context root path
@@ -32,8 +33,11 @@ init_run() {
     require_env MYSQL_PASSWORD
 
     echo "Unpacking war ..."
-    mkdir -p "$WEBAPP_DIR"
-    unzip -q -x "$WAR_FILE" -d "$WEBAPP_DIR"
+    mkdir -p "$UNPACK_DIR"
+    unzip -q -x "$WAR_FILE" -d "$UNPACK_DIR" \
+             -x "WEB-INF/wjHtml/*" \
+             -x "WEB-INF/classes/conf/site/*"
+    ln -snf "$UNPACK_DIR" "$WEBAPP_DIR"
 
     echo "Configuring dwsurvey ..."
     sed -i "s^jdbc.url=.*\$jdbc.url=jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}?useUnicode=true\&characterEncoding=utf8g;