Public | Automated Build

Last pushed: a year ago
Short Description
Container app
Full Description

MiniTwit

Extensions of karlkfi/minitwit, a Twitter clone using Spark (Java), Spring, Freemarker, and HSQLDB or MySQL.

Prerequisites

  • Docker 1.11 or above

Build

  1. Clone the repository and go to the root directory.

     git clone git@github.com:mhausenblas/minitwit.git
     cd minitwit
    
  2. Build the docker image

     docker build -t mhausenblas/minitwit .
    

Usage

  1. Run the docker image in the background

     docker run -d --name minitwit mhausenblas/minitwit
    
  2. Find the docker container's IP

     MINITWIT_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' minitwit)
    
  3. Open MiniTwit in your browser

     http://${MINITWIT_IP}:${SERVER_PORT}/
    
  4. Sign up as a new user

    If your e-mail address has an associated Gravatar image, this will be used as your profile image.

  5. Log in

    Use the credentials created in the previous step to log in.

  6. Post a message

  7. See your message added to the timeline

Configuration

There are several ways to configure MiniTwit using Spring's ServerProperties, but only a few of them are being mapped to SparkJava.

The following environment variables can be passed to MiniTwit through Docker using environment variables:

Name Type Default Description
SERVER_PORT Integer 80 Port on which the server will listen
SPRING_DATASOURCE_URL String jdbc:hsqldb:<db-info> JDBC path to the database
SPRING_DATASOURCE_USERNAME String jdbc:hsqldb:<db-info> Database username
SPRING_DATASOURCE_PASSWORD String <null> Database password
SPRING_DATASOURCE_DRIVER-CLASS-NAME String <auto-detect> JDBC Driver class
SPRING_DATASOURCE_PLATFORM String hsqldb Name of the platform-specific schema to use (hsqldb or mysql)

Databases

By default, MiniTwit uses HyperSQL as an in-memory database.

For persistent storage, use MySQL.

Example MySQL Docker Deployment

# create mysql environment file
cat > mysql.env << EOF
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=minitwit
MYSQL_USER=minitwit
MYSQL_PASSWORD=minitwit
EOF

# start mysql server
docker run -d --name=mysql --env-file=mysql.env mysql:5.7.15

# find mysql IP
MYSQL_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mysql)

# create minitwit environment file
cat > minitwit.env << EOF
SPRING_DATASOURCE_URL=jdbc:mysql://${MYSQL_IP}:3306/minitwit?autoReconnect=true&useSSL=false
SPRING_DATASOURCE_USERNAME=minitwit
SPRING_DATASOURCE_PASSWORD=minitwit
SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.cj.jdbc.Driver
SPRING_DATASOURCE_PLATFORM=mysql
EOF

# start minitwit server
docker run -d --name minitwit --env-file=minitwit.env mhausenblas/minitwit

##License
MIT License

See LICENSE for details.

Docker Pull Command
Owner
mhausenblas
Source Repository

Comments (0)