This is an automated email from the ASF dual-hosted git repository.

gk pushed a commit to branch docker
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git

commit 646e1a17ffa122b2edd310f166a83a1156487550
Author: Georg Kallidis <georg.kalli...@fu-berlin.de>
AuthorDate: Thu Nov 22 17:11:54 2018 +0100

    added docker profile, still EXPERIMENTAL, read docker-info.cmd, until now 
checked only for integration test by running mvn install -Pdocker and then 
proceeding commands from in docker-resources as described in docker-info.md
---
 pom.xml                                            |  48 +++++
 .../META-INF/maven/archetype-metadata.xml          |  10 +
 .../docker-resources/app/Dockerfile                |  30 +++
 .../docker-resources/app/settings.xml              |  69 +++++++
 .../docker-resources/db/Dockerfile                 |  57 ++++++
 .../docker-resources/db/mysql/conf/my.cnf          |  34 ++++
 .../docker-resources/db/mysql/init/data.sql        | 220 +++++++++++++++++++++
 .../docker-resources/db/mysql/log/log.out          |   0
 .../docker-resources/db/mysql/my.cnf               |  15 ++
 .../docker-resources/docker-compose.yml            |  68 +++++++
 .../docker-resources/docker-info.md                | 123 ++++++++++++
 src/main/resources/archetype-resources/pom.xml     |  13 ++
 .../src/main/webapp/WEB-INF/jetty-env.xml          |   2 +-
 .../resources/projects/first/archetype.properties  |   3 +-
 14 files changed, 690 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index f5a829e..ca506bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,10 @@
     
<url>http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-5.0/</url>
   </scm>
   
+  <properties>
+       
<turbine_database_url>jdbc:mysql://localhost:3306/</turbine_database_url>
+  </properties>
+  
 <build>
     <extensions>
       <extension>
@@ -50,6 +54,33 @@
         <version>3.0.1</version>
       </extension>
     </extensions>
+       
+       <plugins>
+       <!-- filtering for docker -->
+       <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>3.1.0</version>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <!-- here the phase you need -->
+            <phase>validate</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${basedir}/target/test-classes</outputDirectory>
+                         <resources>          
+                <resource>
+                  <directory>src/test/resources</directory>
+                  <filtering>true</filtering>
+                </resource>
+              </resources>              
+            </configuration>            
+          </execution>
+        </executions>
+      </plugin>
+       </plugins>
 
     <pluginManagement>
       <plugins>
@@ -64,5 +95,22 @@
       </plugins>
     </pluginManagement>
   </build>
+  
+  <profiles>
+               <!-- to test in integration-test -->
+        <profile>
+            <id>docker</id>
+            <activation>
+              <property>
+                <name>docker</name>
+              </property>
+             </activation>
+             <properties>
+                               
<turbine_database_url>jdbc:mysql://db:3306/</turbine_database_url>
+                               <!-- to provide your locale maven repo, 
required if you need local snapshot builds -->
+                               
<app_volume_local_repo>${settings.localRepository}</app_volume_local_repo>
+            </properties>
+        </profile>
+    </profiles>
 
 </project>
diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml 
b/src/main/resources/META-INF/maven/archetype-metadata.xml
index 4dfe69c..5b4c2dd 100644
--- a/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -54,6 +54,9 @@
     <requiredProperty key="turbine_database_password">
       <defaultValue>db_password</defaultValue>
     </requiredProperty>
+        <requiredProperty key="app_volume_local_repo">
+      <defaultValue>${settings.localRepository}</defaultValue>
+    </requiredProperty>
   </requiredProperties>
   <fileSets>
     <fileSet filtered="true" packaged="true">
@@ -134,5 +137,12 @@
           <include>**/*</include>
         </includes>
     </fileSet>
+    
+    <fileSet filtered="true" packaged="false">
+        <directory>docker-resources</directory>
+        <includes>
+          <include>**/*</include>
+        </includes>
+    </fileSet>
   </fileSets>
 </archetype-descriptor>
diff --git 
a/src/main/resources/archetype-resources/docker-resources/app/Dockerfile 
b/src/main/resources/archetype-resources/docker-resources/app/Dockerfile
new file mode 100644
index 0000000..14cbcd4
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/app/Dockerfile
@@ -0,0 +1,30 @@
+FROM maven:3-jdk-8
+
+ENV APP_ROOT /myapp
+
+# Set our working directory inside the image
+
+RUN mkdir /myapp
+
+WORKDIR /myapp
+
+# cft hub.docker.com/r/library/maven
+COPY ./docker-resources/app/settings.xml /usr/share/maven/ref/
+
+COPY pom.xml /myapp/pom.xml
+COPY src/main/torque-schema/ /myapp/src/main/torque-schema/
+COPY src/main/webapp/ /myapp/src/main/webapp/
+
+# builds app and runs commands connecting to mysql port 13306
+# CMD ["mvn clean install"] 
+# RUN mvn clean install & sleep 10
+
+# copy generated target et al.
+COPY . /myapp/
+
+RUN sleep 5
+
+# do this not in build
+#  mvn jetty:run
+
+
diff --git 
a/src/main/resources/archetype-resources/docker-resources/app/settings.xml 
b/src/main/resources/archetype-resources/docker-resources/app/settings.xml
new file mode 100644
index 0000000..8957322
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/app/settings.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0    
+        http://maven.apache.org/xsd/settings-1.0.0.xsd";>
+<!--settings-->
+  <!-- There might be more configuration here -->
+ <localRepository>/m2repo</localRepository>
+ <usePluginRegistry>false</usePluginRegistry>
+ <offline>false</offline>
+ <pluginGroups>
+    <pluginGroup>org.mortbay.jetty</pluginGroup>
+ </pluginGroups> 
+ <profiles>
+          <profile>
+      <id>nexus</id>
+      <!--Enable snapshots for the built in central repo to direct -->
+      <!--all requests to nexus via the mirror -->
+      <repositories>
+        <repository>
+          <id>releases</id>
+          <url>http://central</url>
+          <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>false</enabled></snapshots>
+        </repository>
+        <repository>
+          <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>true</enabled></snapshots>
+          <id>snapshots</id>
+          <url>http://snapshots</url>
+        </repository>
+      </repositories>
+     <pluginRepositories>
+        <pluginRepository>
+          <id>releases</id>
+          <url>http://central</url>
+          <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>true</enabled></snapshots>
+        </pluginRepository>
+                <pluginRepository>
+         <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>true</enabled></snapshots>
+          <id>snapshots</id>
+          <url>http://snapshots</url>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+    <profile> 
+      <id>repo1</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>central</id>
+          <name>Maven Plugin Repository</name>
+          <url>http://repo1.maven.org/maven2</url>
+          <layout>default</layout>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+          <releases>
+            <updatePolicy>never</updatePolicy>
+          </releases>
+        </pluginRepository>
+     </pluginRepositories> 
+    </profile>
+  </profiles>
+</settings>
diff --git 
a/src/main/resources/archetype-resources/docker-resources/db/Dockerfile 
b/src/main/resources/archetype-resources/docker-resources/db/Dockerfile
new file mode 100644
index 0000000..45dacda
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/db/Dockerfile
@@ -0,0 +1,57 @@
+#using multi-stage
+
+# mariadb use docker-entrypoint 
+FROM mysql:latest  as builder
+
+# That file does the DB initialization but also runs mysql daemon, by removing 
the last line it will only init
+RUN ["/bin/sed", "-i", "s/exec \"$@\"/echo \"not running $@\"/", 
"/usr/local/bin/docker-entrypoint.sh"]
+
+#
+# check where and what configurations are read with e.g.
+# docker-compose run db /usr/sbin/mysqld --verbose --help | grep -A 1 "Default 
options"
+# docker run <image> /usr/sbin/mysqld --verbose --help | grep -A 1 "Default 
options"
+
+ARG DB_CONTEXT
+# mount in docker-compose
+ADD #var("DB_CONTEXT:-.")/mysql/conf/my.cnf /etc/
+
+# for logs
+RUN mkdir /mysql
+RUN chmod a+w /mysql
+
+# for sql
+RUN mkdir /data
+RUN chmod a+w /data
+
+# copy 
+ADD #var("DB_CONTEXT:-.")/mysql/init/*.sql /docker-entrypoint-initdb.d/
+
+# to check what is needed
+ADD ./target/generated-sql/torque/mysql/*.sql ./data/
+ADD ./docs/sample-mysql-data/*.sql ./data/
+
+# required, to create
+ENV DB_CONTEXT #var("DB_CONTEXT")
+
+ENV MYSQL_DATABASE=${turbine_database_name}
+ENV MYSQL_ROOT=root
+ENV MYSQL_ROOT_PASSWORD=default
+ENV MYSQL_USER=${turbine_database_user}
+ENV MYSQL_PASSWORD=${turbine_database_password}
+ENV MYSQL_HOST=
+#ENV MYSQL_RANDOM_ROOT_PASSWORD yes
+
+# Need to change the datadir to something else that /var/lib/mysql because the 
parent docker file defines it as a volume.
+# https://docs.docker.com/engine/reference/builder/#volume :
+#       Changing the volume from within the Dockerfile: If any build steps 
change the data within the volume after
+#       it has been declared, those changes will be discarded.
+
+RUN ["/usr/local/bin/docker-entrypoint.sh", "mysqld", "--datadir", 
"/initialized-db"]
+#RUN /docker-entrypoint.sh mysqld --datadir=/initialized-db && sleep 10 
+
+FROM mysql:latest
+
+# my.cnf setting data-dir 
+COPY --from=builder /initialized-db /var/lib/mysql
+
+
diff --git 
a/src/main/resources/archetype-resources/docker-resources/db/mysql/conf/my.cnf 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/conf/my.cnf
new file mode 100644
index 0000000..95814cd
--- /dev/null
+++ 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/conf/my.cnf
@@ -0,0 +1,34 @@
+# read https://hub.docker.com/_/mysql/
+# 
+
+[mysqld]
+
+#
+# * Basic Settings
+#
+#user            = mysql
+#pid-file        = /var/run/mysqld/mysqld.pid
+#socket          = /var/run/mysqld/mysqld.sock
+
+character-set-server=utf8
+
+# in mysql image VOLUME /var/lib/mysql and any changes to this directory 
+# during build process might got lost after the build step is done 
+# match db_data in docker-compose
+
+datadir     = /initialized-db
+
+#tmpdir          = /tmp
+
+# default 0.0.0.0,  if this is 127.0.0.1 and using docker this restricts 
listening to only inside container, 
+# which does not make sense in docker-compose services 
+# skip-networking,
+#bind-address = 0.0.0.0
+
+[mysql]
+tee=/mysql/log.out
+
+[mysqld_safe]
+#socket          = /var/run/mysqld/mysqld.sock
+nice            = 0
+
diff --git 
a/src/main/resources/archetype-resources/docker-resources/db/mysql/init/data.sql
 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/init/data.sql
new file mode 100644
index 0000000..82a2093
--- /dev/null
+++ 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/init/data.sql
@@ -0,0 +1,220 @@
+-- CREATE DATABASE /*!32312 IF NOT EXISTS*/ `turbine`;
+
+use turbine;
+
+-- database should be creates, if MYSQL_DATABASE is provided
+
+-- -----------------------------------------------------------------------
+-- mysql SQL script for schema turbine
+-- -----------------------------------------------------------------------
+-- set foreign_key_checks=0;
+
+
+drop table if exists TURBINE_PERMISSION;
+drop table if exists TURBINE_ROLE;
+drop table if exists TURBINE_GROUP;
+drop table if exists TURBINE_ROLE_PERMISSION;
+drop table if exists TURBINE_USER;
+drop table if exists TURBINE_USER_GROUP_ROLE;
+
+CREATE TABLE TURBINE_PERMISSION
+(
+    PERMISSION_ID INTEGER NOT NULL AUTO_INCREMENT,
+    PERMISSION_NAME VARCHAR(64) NOT NULL,
+    PRIMARY KEY(PERMISSION_ID),
+    UNIQUE TURBINE_PERMISSION_UQ_1 (PERMISSION_NAME)
+);
+
+
+# -----------------------------------------------------------------------
+# TURBINE_ROLE
+# -----------------------------------------------------------------------
+CREATE TABLE TURBINE_ROLE
+(
+    ROLE_ID INTEGER NOT NULL AUTO_INCREMENT,
+    ROLE_NAME VARCHAR(64) NOT NULL,
+    PRIMARY KEY(ROLE_ID),
+    UNIQUE TURBINE_ROLE_UQ_1 (ROLE_NAME)
+);
+
+
+# -----------------------------------------------------------------------
+# TURBINE_GROUP
+# -----------------------------------------------------------------------
+CREATE TABLE TURBINE_GROUP
+(
+    GROUP_ID INTEGER NOT NULL AUTO_INCREMENT,
+    GROUP_NAME VARCHAR(64) NOT NULL,
+    PRIMARY KEY(GROUP_ID),
+    UNIQUE TURBINE_GROUP_UQ_1 (GROUP_NAME)
+);
+
+
+# -----------------------------------------------------------------------
+# TURBINE_ROLE_PERMISSION
+# -----------------------------------------------------------------------
+CREATE TABLE TURBINE_ROLE_PERMISSION
+(
+    ROLE_ID INTEGER NOT NULL,
+    PERMISSION_ID INTEGER NOT NULL,
+    PRIMARY KEY(ROLE_ID, PERMISSION_ID)
+);
+
+
+# -----------------------------------------------------------------------
+# TURBINE_USER
+# -----------------------------------------------------------------------
+CREATE TABLE TURBINE_USER
+(
+    USER_ID INTEGER NOT NULL AUTO_INCREMENT,
+    LOGIN_NAME VARCHAR(64) NOT NULL,
+    PASSWORD_VALUE VARCHAR(16) NOT NULL,
+    FIRST_NAME VARCHAR(64) NOT NULL,
+    LAST_NAME VARCHAR(64) NOT NULL,
+    EMAIL VARCHAR(64),
+    CONFIRM_VALUE VARCHAR(16),
+    MODIFIED_DATE DATETIME,
+    CREATED DATETIME,
+    LAST_LOGIN DATETIME,
+    OBJECTDATA MEDIUMBLOB,
+    PRIMARY KEY(USER_ID),
+    UNIQUE TURBINE_USER_UQ_1 (LOGIN_NAME)
+);
+
+
+# -----------------------------------------------------------------------
+# TURBINE_USER_GROUP_ROLE
+# -----------------------------------------------------------------------
+CREATE TABLE TURBINE_USER_GROUP_ROLE
+(
+    USER_ID INTEGER NOT NULL,
+    GROUP_ID INTEGER NOT NULL,
+    ROLE_ID INTEGER NOT NULL,
+    PRIMARY KEY(USER_ID, GROUP_ID, ROLE_ID)
+);
+
+
+ALTER TABLE TURBINE_ROLE_PERMISSION
+    ADD CONSTRAINT TURBINE_ROLE_PERMISSION_FK_1
+    FOREIGN KEY (ROLE_ID)
+    REFERENCES TURBINE_ROLE (ROLE_ID);
+
+ALTER TABLE TURBINE_ROLE_PERMISSION
+    ADD CONSTRAINT TURBINE_ROLE_PERMISSION_FK_2
+    FOREIGN KEY (PERMISSION_ID)
+    REFERENCES TURBINE_PERMISSION (PERMISSION_ID);
+
+ALTER TABLE TURBINE_USER_GROUP_ROLE
+    ADD CONSTRAINT TURBINE_USER_GROUP_ROLE_FK_1
+    FOREIGN KEY (USER_ID)
+    REFERENCES TURBINE_USER (USER_ID);
+
+ALTER TABLE TURBINE_USER_GROUP_ROLE
+    ADD CONSTRAINT TURBINE_USER_GROUP_ROLE_FK_2
+    FOREIGN KEY (GROUP_ID)
+    REFERENCES TURBINE_GROUP (GROUP_ID);
+
+ALTER TABLE TURBINE_USER_GROUP_ROLE
+    ADD CONSTRAINT TURBINE_USER_GROUP_ROLE_FK_3
+    FOREIGN KEY (ROLE_ID)
+    REFERENCES TURBINE_ROLE (ROLE_ID);
+
+
+-- -----------------------------------------------------------------------
+-- mysql SQL script for schema turbine
+-- -----------------------------------------------------------------------
+
+
+drop table if exists AUTHOR;
+drop table if exists BOOK;
+
+
+
+# -----------------------------------------------------------------------
+# AUTHOR
+# -----------------------------------------------------------------------
+CREATE TABLE AUTHOR
+(
+    AUTH_ID INTEGER NOT NULL,
+    FIRST_NAME VARCHAR(64) NOT NULL,
+    LAST_NAME VARCHAR(64) NOT NULL,
+    PRIMARY KEY(AUTH_ID)
+);
+
+
+# -----------------------------------------------------------------------
+# BOOK
+# -----------------------------------------------------------------------
+CREATE TABLE BOOK
+(
+    BOOK_ID INTEGER NOT NULL,
+    AUTH_ID INTEGER NOT NULL,
+    TITLE VARCHAR(64) NOT NULL,
+    SUBJECT VARCHAR(64) NOT NULL,
+    PRIMARY KEY(BOOK_ID)
+);
+
+
+ALTER TABLE BOOK
+    ADD CONSTRAINT BOOK_FK_1
+    FOREIGN KEY (AUTH_ID)
+    REFERENCES AUTHOR (AUTH_ID);
+
+
+
+
+SET FOREIGN_KEY_CHECKS=0;
+
+INSERT INTO TURBINE_USER 
(USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
+    VALUES (1,'admin','password','','Admin');
+
+INSERT INTO TURBINE_USER 
(USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
+    VALUES (2,'user','password','','User');
+    
+INSERT INTO TURBINE_USER 
(USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
+    VALUES (3,'anon','nopw','','Anon');
+
+INSERT INTO TURBINE_PERMISSION (`PERMISSION_ID`, `PERMISSION_NAME`) VALUES
+(2, 'Turbine'),
+(1, 'TurbineAdmin');
+
+INSERT INTO TURBINE_ROLE (`ROLE_ID`, `ROLE_NAME`) VALUES
+(1, 'turbineadmin'),
+(2, 'turbineuser');
+
+INSERT INTO TURBINE_GROUP (`GROUP_ID`, `GROUP_NAME`) VALUES
+(1, 'global'),
+(2, 'Turbine');
+
+INSERT INTO TURBINE_ROLE_PERMISSION (`ROLE_ID`, `PERMISSION_ID`) VALUES
+(1, 1),
+(2, 2);
+
+INSERT INTO TURBINE_USER_GROUP_ROLE (`USER_ID`, `GROUP_ID`, `ROLE_ID`) VALUES
+(1, 1, 1),
+(1, 2, 1),
+(2, 2, 2),
+(2, 1, 2);
+
+-- 
+ALTER TABLE TURBINE_USER MODIFY COLUMN USER_ID INT auto_increment;
+ALTER TABLE TURBINE_PERMISSION MODIFY COLUMN PERMISSION_ID INT auto_increment;
+ALTER TABLE TURBINE_ROLE MODIFY COLUMN ROLE_ID INT auto_increment;
+ALTER TABLE TURBINE_GROUP MODIFY COLUMN GROUP_ID INT auto_increment;
+
+
+    
+
+
+
+INSERT INTO AUTHOR (AUTH_ID, FIRST_NAME, LAST_NAME) values (1, 'Donald', 
'Knuth');
+INSERT INTO AUTHOR (AUTH_ID, FIRST_NAME, LAST_NAME) values (2, 'Mickey', 
'Mouse' );
+INSERT INTO AUTHOR (AUTH_ID, FIRST_NAME, LAST_NAME) values (3, 'Bill', 
'Bryson' );
+
+INSERT INTO BOOK ( BOOK_ID, AUTH_ID, TITLE, SUBJECT ) values ( 1, 1, 'The Art 
of Computer Programming', 'Computer Science');
+INSERT INTO BOOK ( BOOK_ID, AUTH_ID, TITLE, SUBJECT ) values ( 2, 2, 'Disney: 
Behind the Scenes', 'Fiction' );
+INSERT INTO BOOK ( BOOK_ID, AUTH_ID, TITLE, SUBJECT ) values ( 3, 3, 'A Walk 
in the Woods', 'Fiction');-- 
-----------------------------------------------------------------------
+-- mysql SQL script for schema turbine
+-- -----------------------------------------------------------------------
+
+SET foreign_key_checks=1;
\ No newline at end of file
diff --git 
a/src/main/resources/archetype-resources/docker-resources/db/mysql/log/log.out 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/log/log.out
new file mode 100644
index 0000000..e69de29
diff --git 
a/src/main/resources/archetype-resources/docker-resources/db/mysql/my.cnf 
b/src/main/resources/archetype-resources/docker-resources/db/mysql/my.cnf
new file mode 100644
index 0000000..c912794
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/db/mysql/my.cnf
@@ -0,0 +1,15 @@
+[mysqld]
+character-set-server=utf8
+
+# in mysql image VOLUME /var/lib/mysql and any changes to this directory 
+# during build process might got lost after the build step is done 
+# match db_data in docker-compose
+# datadir     = /var/lib/mysql2
+
+# default 0.0.0.0,  if this is 127.0.0.1 and using docker this restricts 
listening to only inside container, 
+# which does not make sense in docker-compose services 
+# skip-networking,
+#bind-address = 0.0.0.0
+
+[mysql]
+tee=/mysql/log.out
\ No newline at end of file
diff --git 
a/src/main/resources/archetype-resources/docker-resources/docker-compose.yml 
b/src/main/resources/archetype-resources/docker-resources/docker-compose.yml
new file mode 100644
index 0000000..d5a84e1
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/docker-compose.yml
@@ -0,0 +1,68 @@
+# service configuration for our dockerized Java app
+version: '3'
+
+services:
+  app:
+    # use the Dockerfile next to this file
+    build:
+        context: ../
+        dockerfile: ./docker-resources/app/Dockerfile
+    # optional environment variable configuration for app
+    # this runs the app server in the container
+    #command: mvn package jetty:run -Pdocker
+    command: mvn jetty:run
+    ports:
+      - "8081:8081"
+      - "8080:8080"
+    # makes the app container aware of the DB container   
+    depends_on:
+      - db 
+    # 
+    #expose:
+    #  - "3000"
+    volumes:
+      - ../:/myapp
+      - "${app_volume_local_repo}:/m2repo"
+    #networks:
+    #  - db
+
+  db:
+      # set the build context 
+    build: 
+      context: ../
+      dockerfile: ./docker-resources/db/Dockerfile
+      args:
+        - DB_CONTEXT=${DB_CONTEXT}
+    
+    environment:
+      - MYSQL_DATABASE=${turbine_database_name}
+      - MYSQL_HOST= 
+      - MYSQL_ROOT_PASSWORD=default
+      - MYSQL_USER=${turbine_database_user}
+      - MYSQL_PASSWORD=${turbine_database_password}
+      - DB_CONTEXT=./docker-resources/db
+      #- MYSQL_RANDOM_ROOT_PASSWORD=yes
+      
+    volumes:
+      - "./db/mysql/init:/docker-entrypoint-initdb.d" 
+      - mysql_log:/mysql:rw 
+      # parent folder -> /etc/mysql/conf.d/*.cnf settings taking precedence.
+      - "/db/mysql/conf:/etc/mysql/conf.d"
+      # default mysql persistent data
+      #- db_data:/var/lib/mysql2:rw  
+      - "./db/mysql/data:/data" 
+    restart: always     
+    ports:
+    # host: port
+      - "13306:3306" 
+    #networks:
+    #  - db
+    #command: [mysqld, --character-set-server=utf8mb4, 
--collation-server=utf8mb4_unicode_ci]
+    command: --default-authentication-plugin=mysql_native_password
+
+volumes:
+  #db_data:
+  mysql_log:
+  
+#networks:
+#  db:
diff --git 
a/src/main/resources/archetype-resources/docker-resources/docker-info.md 
b/src/main/resources/archetype-resources/docker-resources/docker-info.md
new file mode 100644
index 0000000..84bfe34
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/docker-info.md
@@ -0,0 +1,123 @@
+# Installation
+
+- If not done, run build
+```
+$ mvn clean install -Pdocker
+```
+Change into docker resource folder
+``` 
+cd docker-resources
+``` 
+
+Optional Cleanup
+``` 
+docker-compose down
+docker-compose down -v
+docker system prune
+docker volume rm $(docker volume ls -qf dangling=true)
+
+``` 
+
+Build Services
+``` 
+ docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db
+``` 
+DB_CONTEXT is set to allow starting the db container standalone (in folder db, 
e.g. with docker build --tag my-db .) to test it.
+
+Start all services
+``` 
+docker-compose up
+``` 
+
+Test Database
+
+```
+# start service
+docker-compose up db
+docker-compose run db /bin/sh --build-arg DB_CONTEXT=./docker-resources/db
+#or
+ docker-compose exec db mysql -u root --password=... -e "show databases;" 
--build-arg DB_CONTEXT=./docker-resources/db
+ docker-compose exec db sh -c 'exec mysqldump --all-databases -uroot -p...' 
--build-arg DB_CONTEXT=./docker-resources/db > dump.sql
+
+// check mysql in service container db
+# mysql -u root -h db -P 3306 -p
+
+```
+
+##  Unable to setup unix socket lock file.
+touch /var/run/mysqld/mysqld.sock.lock
+
+## ERROR 2003 (HY000): Can't connect to MySQL server on 'db' (111)
+
+
+#Facts
+
+- Check volumes
+
+OS Problems
+
+Windows
+
+- Replace Backslashes to Slashes in docker-compose form localRepository
+
+- check COMPOSE_CONVERT_WINDOWS_PATHS, 
https://docs.docker.com/compose/reference/envvars/#compose_convert_windows_paths
+
+
+- If image download fails, try Docker->Network->Update DNS to 8.8.8.8
+
+- ERROR: for db  Cannot start service db: driver failed programming external 
connectivity on endpoint docker-resources_d
+
+  - -> https://github.com/docker/for-win/issues/573 Best answer:
+
+       1. docker rm $(docker ps -a -q)
+       2. Stop the Docker on your machine & restart it.
+
+
+Resetting / Preparation (optional)
+
+```  
+  $ docker-compose rm -v
+```  
+
+```
+
+Delete all images
+$ docker rmi $(docker images -q)
+```
+  
+Check if something is there ..
+```
+  docker-compose ps
+``` 
+
+first build, this requires /generated-sql :
+ ```
+ $ mvn clean package
+ $ docker-compose build
+```
+or
+$ docker-compose build --no-cache
+ 
+Then run
+```
+$ docker-compose up
+```
+
+Internals
+
+```
+  docker-machine ls
+  docker ps  
+  docker-compose ps
+  docker-compose up --build
+  
+  delete intermediate / show images
+  docker rmi $(docker images --filter "dangling=true" -q)
+  # or delete while building
+  docker build --rm
+  # cleans all containers
+  docker system prune
+  
+  # stops all running containers  
+  docker stop $(docker ps -a -q)
+```  
diff --git a/src/main/resources/archetype-resources/pom.xml 
b/src/main/resources/archetype-resources/pom.xml
index 430c33e..9415dc9 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -449,6 +449,19 @@ under the License.
                 </plugins>
             </build>
         </profile>
+                <profile>
+            <id>docker</id>
+            <activation>
+              <property>
+                <name>docker</name>
+              </property>
+             </activation>
+             <properties>
+                
<turbine_database_url>jdbc:mysql://db:3306/</turbine_database_url>
+                               <!-- to provide e.g. local snapshot builds -->
+                               
<app_volume_local_repo>#var("settings.localRepository")</app_volume_local_repo>
+            </properties>
+        </profile>
     </profiles>
     
 </project>
diff --git 
a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml 
b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
index 83a724f..6512119 100644
--- 
a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
+++ 
b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
@@ -8,7 +8,7 @@
              <Set 
name="url">${turbine_database_url}${turbine_database_name}</Set>
             <Set name="username">${turbine_database_user}</Set>
             <Set name="password">${turbine_database_password}</Set>
-            <Set 
name="connectionProperties">serverTimezone=${turbine_database_timezone};useUnicode=true;characterEncoding=utf8;</Set>
+            <Set 
name="connectionProperties">serverTimezone=${turbine_database_timezone};useUnicode=true;characterEncoding=utf8;useSSL=false;allowPublicKeyRetrieval=true</Set>
             <Set name="validationQuery">SELECT 1</Set>          
         </New>
     </Arg>
diff --git a/src/test/resources/projects/first/archetype.properties 
b/src/test/resources/projects/first/archetype.properties
index 1155d78..1d7a742 100644
--- a/src/test/resources/projects/first/archetype.properties
+++ b/src/test/resources/projects/first/archetype.properties
@@ -9,6 +9,7 @@ turbine_database_adapter=auto
 turbine_database_jndipath=jdbc/turbine
 turbine_database_driver=com.mysql.cj.jdbc.Driver
 turbine_database_timezone=UTC
-turbine_database_url=jdbc:mysql://localhost:3306/
+turbine_database_url=${turbine_database_url}
 turbine_database_user=db_user
 turbine_database_password=db_password
+app_volume_local_repo=${app_volume_local_repo}

Reply via email to