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 e66847506dc54d7c37a6a10c03ff6f088d409558
Author: Georg Kallidis <georg.kalli...@fu-berlin.de>
AuthorDate: Tue Nov 27 10:29:06 2018 +0100

    renamed docker-info, updated docker docs, documented in changes, fix docker 
property setting, use docker property for skipping create-db
---
 pom.xml                                            |   3 +
 src/changes/changes.xml                            |   5 +-
 .../docker-resources/docker-info.md                | 138 ------------------
 .../archetype-resources/docker-resources/readme.md | 155 +++++++++++++++++++++
 src/main/resources/archetype-resources/pom.xml     |   4 +-
 5 files changed, 165 insertions(+), 140 deletions(-)

diff --git a/pom.xml b/pom.xml
index ca506bc..2b780d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,8 @@
   
   <properties>
        
<turbine_database_url>jdbc:mysql://localhost:3306/</turbine_database_url>
+    <docker>false</docker>
+    <app_volume_local_repo>not_used</app_volume_local_repo>
   </properties>
   
 <build>
@@ -109,6 +111,7 @@
                                
<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>
+                <docker>true</docker>
             </properties>
         </profile>
     </profiles>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 70d544e..cf4f1d1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -25,7 +25,10 @@
 
   <body>
        <release version="1.0.3" date="in Gitbox">
-         <action type="update" dev="jp">
+          <action type="update" dev="gk">
+         Added Docker profile (maven + mysql) for development
+      </action>
+      <action type="update" dev="jp">
          Update to from lang to lang3
       </action>
          <action type="update" dev="jp">
diff --git 
a/src/main/resources/archetype-resources/docker-resources/docker-info.md 
b/src/main/resources/archetype-resources/docker-resources/docker-info.md
deleted file mode 100644
index 297455c..0000000
--- a/src/main/resources/archetype-resources/docker-resources/docker-info.md
+++ /dev/null
@@ -1,138 +0,0 @@
-# Installation
-
-- If not yet 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 volume rm $(docker volume ls -qf dangling=true)
-docker system prune
-``` 
-
-Build Services
-``` 
- docker-compose build --no-cache --build-arg DB_CONTEXT=./docker-resources/db
- 
- // build only app
- // docker-compose build --no-cache app
- // docker-compose build --no-cache --build-arg 
DB_CONTEXT=./docker-resources/db 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.
-
-Builds db, populates it with (hard coded data and prepares application.
-
-Start all services
-``` 
-docker-compose up
-
-// docker-compose up db
-``` 
-Jetty is run and exposes the webapp to http://localhost:80801/app
-
-#Test Services: App, Database
-
-## Start service
-
-```
-docker-compose run --rm db /bin/sh --build-arg DB_CONTEXT=./docker-resources/db
-```
-Extract data in db-Service
-```
- // check mysql in service container db
- // # mysql -u root -h db -P 3306 -p
- // 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
-
-```
-- Service app
-```
-docker-compose up app 
-docker-compose run --rm app /bin/sh 
-// ls -la /myapp // should list pom.xml ...
-```
-
-# Windows
-
-## Powershell
-
-- Replace backslashes to slashes in docker-compose.yml in 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.
-
-## Windows Subsystem for Linux (WSL)
-
-- Check file permissions of archetype generated files (chmod -R a+rw 
docker-resources, chmod -R a+rw src .
-
-- 
https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
-
-
-
-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/docker-resources/readme.md 
b/src/main/resources/archetype-resources/docker-resources/readme.md
new file mode 100644
index 0000000..4fdd170
--- /dev/null
+++ b/src/main/resources/archetype-resources/docker-resources/readme.md
@@ -0,0 +1,155 @@
+# Introduction
+
+This docker environment is to test/develop a Turbine app using a docker test 
database. 
+
+It uses two services: **app** (maven:3-jdk-8) and **db** (mysql:latest), see 
docker-compose.yml. 
+
+## Note
+- Mysql should easily be replacable by mariadb. 
+- Instead of using maven the app service as a build using a Jetty container 
might be the better choice as currently console reloading might not work).
+
+# Installation
+
+- Change into docker resource folder
+
+```sh
+cd docker-resources
+``` 
+- Check services in docker-compose.yml (volumes) 
+``` 
+docker-compose config
+```   
+- Check **src/main/webapp/WEB-INF/jetty-env.xml**. It should reference the 
service name (db) not localhost.
+```
+<Set name="url">jdbc:mysql://db:3306/turbine</Set>
+```
+- Optionally Check system, Cleanup
+```
+docker-compose ps
+```
+- If services are already installed, activate by 
+```
+docker-compose up
+```    
+- or remove by
+```
+docker-compose down and docker-compose down -v
+```
+- If not yet done, run as an initial step a local maven build. Maven install 
build is set as a **command** in app service, that is this done then also.
+The docker profile should be activated by default (if not add -Pdocker). 
+
+```sh
+$ mvn clean install -f ../pom.xml
+```
+
+### Build Services
+ 
+    docker-compose build --no-cache --build-arg 
DB_CONTEXT=./docker-resources/db
+ 
+ .. or build separately
+ 
+    docker-compose build --no-cache --build-arg 
DB_CONTEXT=./docker-resources/db db
+    
+ .. building app service first/only requires removing the dependency in 
docker-compose.yml(comment depends_on: db)
+ 
+    docker-compose build --no-cache app
+
+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. The db service is build and populated till now with hard coded 
data, it is a dependency for the service app (see app/Dockerfile).
+
+
+### Starting Services
+
+Start both services in  one step
+``` 
+docker-compose up
+```    
+.. or doing it in background, requires second start command
+``` 
+docker-compose -d up
+docker-compose start
+``` 
+// docker-compose up db
+
+Jetty is run and exposes the webapp to **http://localhost:8081/app**
+
+#### Lifecycle (developers only)
+
+- If you generate the archetype itself, you might have to stop the services 
before cleaning up (docker-compose stop).
+
+### Test Services: Db, App
+
+## Db Service 
+``` 
+docker-compose run --rm db /bin/sh --build-arg DB_CONTEXT=./docker-resources/db
+``` 
+Extract data in db service
+
+```sh
+ mysql -u root -h db -P 3306 -p
+```
+.. 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
+
+## App Service
+```sh
+docker-compose up app 
+docker-compose run --rm app /bin/sh 
+``` 
+In the container, check:
+```sh
+ls -la /myapp // should list pom.xml ...
+```
+
+# Windows
+
+## Powershell
+
+- Replace in volume path backslashes to slashes "/" in docker-compose.yml in 
localRepository
+
+- check COMPOSE_CONVERT_WINDOWS_PATHS, 
https://docs.docker.com/compose/reference/envvars/#compose_convert_windows_paths
+
+- If a 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_db_1 ..
+
+  - Check if containers not already running.
+  - Remove containers (if any): docker rm $(docker ps -a -q)
+  - If error still there, restart Docker on your machine & restart it.
+
+## Windows Subsystem for Linux (WSL)
+
+- Check file permissions of archetype generated files (chmod -R a+rw 
docker-resources, chmod -R a+rw src .
+
+- 
https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
+
+
+## More Internals, Helpful Docker commands
+
+### Resetting / Preparation (optional)
+
+    docker-compose rm -v
+
+###  Delete all images
+    docker rmi $(docker images -q)
+
+### Still more docker commands ...
+
+```
+  docker ps  
+ 
+  // delete intermediate images, volumes
+  docker rmi $(docker images --filter "dangling=true" -q)
+  docker volume rm $(docker volume ls -qf dangling=true)
+  
+  # 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 603cc3a..9a90d3d 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -209,6 +209,7 @@ under the License.
                   <goal>execute</goal>
                 </goals>
                 <configuration>
+                  <skip>${docker}</skip>
                   <orderFile>ascending</orderFile>
                   <fileset>
                     
<basedir>#var("project.build.directory")/generated-sql/torque/mysql</basedir>
@@ -217,7 +218,7 @@ under the License.
                       <include>*.sql</include>
                     </includes>
                   </fileset>
-              </configuration>
+                </configuration>
             </execution>
             <execution>
               <id>create-data</id>
@@ -226,6 +227,7 @@ under the License.
                 <goal>execute</goal>
               </goals>
               <configuration>
+                <skip>${docker}</skip>
                 <orderFile>ascending</orderFile>
                 <srcFiles>
                   
<srcFile>#var("project.basedir")/docs/sample-mysql-data/_application-data.sql</srcFile>

Reply via email to