Sign inSign up

mhausenblas/minitwit

By mhausenblas

•Updated almost 10 years ago

Container app

Image
0

1.3K

mhausenblas/minitwit repository overview

⁠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 [email protected]: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:

NameTypeDefaultDescription
SERVER_PORTInteger80Port on which the server will listen
SPRING_DATASOURCE_URLStringjdbc:hsqldb:JDBC path to the database
SPRING_DATASOURCE_USERNAMEStringjdbc:hsqldb:Database username
SPRING_DATASOURCE_PASSWORDString<null>Database password
SPRING_DATASOURCE_DRIVER-CLASS-NAMEString<auto-detect>JDBC Driver class
SPRING_DATASOURCE_PLATFORMStringhsqldbName 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.

Tag summary

Content type

Image

Digest

Size

76.4 MB

Last updated

almost 10 years ago

docker pull mhausenblas/minitwit