Commit 44c54328 by Raphael Mäder

Merge branch 'PLAY-174' into 'master'

Add possibility run play-cms-demo without Docker Closes PLAY-174 See merge request !100
parents 3b4e2f5b 319ba6f6
Pipeline #11777 passed with stages
in 20 minutes 1 second
-Dsbt.global.base=project/.sbtboot
-Dsbt.boot.directory=project/.boot
-Dsbt.ivy.home=project/.ivy
-Dplaycms.version=local
#-J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
-Denvironment=docker
-Dconfig.resource=docker.conf
#-J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999
-J-Xms256m
-J-Xmx2g
-J-XX:MaxMetaspaceSize=512m
# Please uncomment next line if you want want to develop the play-cms modules
# -Dplaycms.version=local
# Play-CMS Demo #
This is a Play framework demo application built with [insign](http://www.insign.ch)s **play-cms** - a java-based Play
This is a Play framework demo application built with [insign](http://www.insign.ch)'s **play-cms** - a java-based Play
framework CMS.
This demo creates some demo content and uses the h2 in-memory db for storage. It is intended to be used as
This project creates some demo content and uses a h2 in-memory db for storage. It is intended to be used as
quick-and-easy starting point for your own play-cms project. We've also added a docker-based devops setup for a CI
(continuous integration) process.
......@@ -12,8 +12,7 @@ Check out the [play-cms](http://www.play-cms.com) website for more information a
## Quick start
Either do a local installation (if you have the play framework installed) using H2 by default, or run it in Docker which
uses MySQL database by default.
Either do a local installation using H2 by default, or run it with Docker which uses a MySQL database by default.
### Local installation ###
......@@ -25,6 +24,9 @@ By default, the application will be running on [http://localhost:9000/]() and us
After starting up the application, you need to execute the bootstrap code by calling [http://localhost:9000/reset](),
otherwise you will get an error.
Be aware that you won't be able to use the file manager for adding images/files to the WYSIWYG editor. For that,
you'd have to use the dockerized setup (instructions below).
### Backend Access ###
Default admin page url: [http://localhost:9000/admin]()
......@@ -37,46 +39,44 @@ Default admin page url: [http://localhost:9000/admin]()
## Development environment and Continuous Integration ##
The project contains both a development environment and continuous integration setup (based on docker) for quick
starting new projects.
starting new projects.
### Use the development environment ###
- Make sure you have `docker` and `docker-compose` installed
- The `services.sh` is a helper script which initializes required environment variables and forwards a passed command to
either `docker-compose` or `sbt` commands:
- `services.sh [docker-compose arguments...]` - run full docker stack
- `services.sh sbt [sbt arguments...]` - run `sbt` command along with all docker containers except `app` container
- The bound tcp ports at `services.yml` and `sbt.yml` are configurable via environment variables which may be overridden
in `./devops/.env` file
- SBT options can be specified in `./.sbtopts` file, but it must be noted that a line feed is required at file end
because otherwise the last option will be ignored by sbt
- Make sure you have `docker` and `sbt` installed
- SBT options can be specified in `./.sbtopts` file. It must be noted that a line feed is required at the end of
the file because otherwise the last option will be ignored by sbt
- To enable based on docker environment execute the following command in your project root folder:
cp .sbtopts-example .sbtopts
To quick start the project with this setup, run
cp devops/.env-example devops/.env
devops/services.sh sbt
and then navigate to [http://localhost/](). Please be aware that on computers using `docker-machine`, you'll have to
change `localhost` with the IP of your Docker machine, in the browser as well as the `.env` file.
sbt run
The application will be running on [http://localhost:9000/]().
The environment features these dockerized applications:
- MySQL with PHPMyAdmin under [http://localhost/~pma/]()
- Mailhog SMTP server and mail viewer under [http://localhost/~mail/]()
- MySQL on port 3306, database: db_play-cms-demo, user: play-cms-demo, password: s3cr3t (can be changed in `build.sbt`)
- Mailhog SMTP server and mail viewer under [http://localhost:8025/]()
- Filemanager under [http://localhost:8035/]()
As with the setup not using docker, you will have to call the `/reset` route after starting the application for the
first time.
Sometimes (depending on your OS' `umask` settings) you will need add permissions in ./data folder (where all docker
volumes are mapped)
### Developing the play modules ##
If you want to develop the play-cms modules, execute the following commands in your project root folder:
If you want to develop the play-cms modules, uncomment next line in `./.sbtopts` file:
-Dplaycms.version=local
Then execute the following commands in your project root folder:
```
cp .sbtopts-example .sbtopts
mkdir modules
cd modules
git clone ssh://git@sshgit.insign.rocks:10022/open-source/play-cms/play-cms.git
```
cd ..
git clone ssh://git@sshgit.insign.rocks:10022/open-source/play-cms/play-cms.git
## Developing the demo project itself ##
......@@ -90,7 +90,7 @@ Credentials will be asked on first time.
Note: bintray doesn't support snapshots.
Current version of a module can be easily removed from bintray with
The current version of a module can be easily removed from bintray with
sbt bintrayUnpublish
......
......@@ -59,8 +59,9 @@ lazy val server = (project in file("server"))
// -J params will be added as jvm parameters
"-J-Xmx2g",
"-J-Xms256m"
),
)
)
.settings(if (Settings.withDocker) Seq(
devSettings := {
val envVars = Map(
"APPLICATION_HOST" -> "localhost",
......@@ -83,7 +84,6 @@ lazy val server = (project in file("server"))
}
envVars.toSeq
},
dockerContainers := Seq(
/*DockerContainer(
id = "elasticsearch",
......@@ -147,7 +147,20 @@ lazy val server = (project in file("server"))
)
)
)
)
) else Seq(
devSettings := {
val envVars = Map(
"APPLICATION_HOST" -> "localhost",
"MYSQL_DATABASE" -> "db_play-cms-demo",
"MYSQL_USER" -> "play-cms-demo",
"MYSQL_PASSWORD" -> "s3cr3t"
)
envVars.foreach { case (k, v) =>
java.lang.System.setProperty(k, v)
}
envVars.toSeq
}
))
.enablePlugins(PlayJava, SbtWeb, DockerPlugin, DockerRun)
.dependsOn(sharedJvm)
.devModules(
......
......@@ -97,6 +97,9 @@ object Settings {
val playCmsVersion: String = devmodVersion("playcms.version", versions.playCms)
val playCmsLocal: Boolean = devmodIsLocal("playcms.version")
/** Environment: dockerized or simple*/
val withDocker: Boolean = isRunWithDocker("environment")
/** Dependencies only used by the JS project (note the use of %%% instead of %%) */
val scalajsDependencies = Def.setting(Seq(
"org.scala-js" %%% "scalajs-dom" % versions.scalajsDom,
......@@ -133,4 +136,8 @@ object Settings {
sys.props.get(prop).filter(_ != "local").getOrElse(default)
}
private def isRunWithDocker(prop: String): Boolean = {
sys.props.get(prop).exists(_ == "docker")
}
}
......@@ -40,8 +40,8 @@ application.cdn = ""
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
db.default {
driver = com.mysql.jdbc.Driver
url = "jdbc:mysql://"${MYSQL_HOST}":"${MYSQL_PORT}"/"${MYSQL_DATABASE}"?autoReconnect=true&sessionVariables=default_storage_engine=MyISAM,sql_mode=ANSI_QUOTES"
driver = org.h2.Driver
url = "jdbc:h2:mem:play-cms;MODE=MySQL"
username = ${?MYSQL_USER}
password = ${?MYSQL_PASSWORD}
jndiName = "DefaultDS"
......@@ -112,8 +112,8 @@ cms {
wwwroot = /uploads
}
filemanager.enable = true
filemanager.urlPrefix = ${FILEMANAGER_BASE_URL}
filemanager.enable = false
filemanager.urlPrefix = ""
enableResetRoute = true
......
include "application.conf"
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
db.default {
driver = com.mysql.jdbc.Driver
url = "jdbc:mysql://"${MYSQL_HOST}":"${MYSQL_PORT}"/"${MYSQL_DATABASE}"?autoReconnect=true&sessionVariables=default_storage_engine=MyISAM,sql_mode=ANSI_QUOTES"
username = ${?MYSQL_USER}
password = ${?MYSQL_PASSWORD}
jndiName = "DefaultDS"
# You can turn on SQL logging for any datasource
# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
#default.logSql=true
}
cms {
filemanager.enable = true
filemanager.urlPrefix = ${FILEMANAGER_BASE_URL}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment