Sign inSign up

toniin/api-contact-manager

By toniin

•Updated about 2 years ago

Image
0

186

toniin/api-contact-manager repository overview

⁠API Contact manager

This docker image is an API build with Java Spring.
It works on port 8080 and need to be connected to mysql or mongodb database.

⁠You need to add environment variables :

  • ALLOWED_ORIGINS: List of url(s) application allowed to communicate with the API

  • DATABASE_URL: Url/Ip adress of the database | name of the database container

  • DATABASE_USERNAME: Username to connect to database

  • DATABASE_PASSWORD: Password to connect to database

  • JWT_SECRET_KEY: Secret key to signing/verifying the JWT tokens
    You can generate it with this command :

openssl rand -base64 32
  • JWT_EXPIRATION_TIME: Time in milliseconds
⁠If you choose mysql database :
  • MYSQL_DATABASE: Name of the database where data is store
⁠Example of docker-compose-yml (mysql)
api:
  image: toniin/api-contact-manager:tag-sql
  restart: always
  container_name: api
  environment:
    ALLOWED_ORIGINS: "http://localhost:4200"
    DATABASE_URL: "mysql_db"
    MYSQL_DATABASE: "db_name"
    DATABASE_USERNAME: "mysql"
    DATABASE_PASSWORD: "password"
    JWT_SECRET_KEY: "qzHUL7P9M/GPVu/XOF/oON7OHzFn8/OgXzFuVhMMRlM="
    JWT_EXPIRATION_TIME: "300000"
  networks:
    - app
    - mysql
  ports:
    - '8888:8080'
  depends_on:
    - mysql_db
⁠If you choose mongodb database :
  • DATABASE_PORT: Port of the mongodb database

  • MONGODB_DATABASE: Name of the database where data is store

⁠Example of docker-compose-yml (mongodb)
api:
  image: toniin/api-contact-manager:tag-mongodb
  restart: always
  container_name: api
  environment:
    ALLOWED_ORIGINS: "http://localhost:4200"
    DATABASE_URL: "mongo_db"
    DATABASE_PORT: "27017"
    MONGODB_DATABASE: "db_name"
    DATABASE_USERNAME: "mongodb"
    DATABASE_PASSWORD: "password"
    JWT_SECRET_KEY: "qzHUL7P9M/GPVu/XOF/oON7OHzFn8/OgXzFuVhMMRlM="
    JWT_EXPIRATION_TIME: "300000"
  networks:
    - app
    - mongodb
  ports:
    - '8888:8080'
  depends_on:
    - mongo_db

⁠Suggestion:

toniin/contact-manager-angular⁠
toniin/contact-manager-react⁠
toniin/contact-manager-vue⁠

mysql⁠

mysql_db:
  image: mysql:lts
  restart: always
  container_name: mysql_db
  environment:
    MYSQL_DATABASE: "db_name"
    MYSQL_ROOT_PASSWORD: "password"
  networks:
    - mysql_db
  ports:
    - '3306:3306'
  volumes:
    - mysql:/var/lib/mysql

mongodb community server⁠

mongodb:
  container_name: mongodb
  image: mongodb/mongodb-community-server:6.0-ubi8
  restart: always
  environment:
    - MONGO_INITDB_DATABASE=db_name
    - MONGODB_INITDB_ROOT_USERNAME=root
    - MONGODB_INITDB_ROOT_PASSWORD=password
  networks:
    - app
    - mongodb
    - mongo-express
  ports:
    - "27017:27017"
  volumes:
    - mongodb:/data/mongodb
  • ⁠Monitoring database

mongo express⁠

mongo-express:
  container_name: mongo-express
  image: mongo-express
  restart: always
  depends_on:
    - mongodb
  networks:
    - mongo-express
  environment:
    - ME_CONFIG_MONGODB_SERVER=mongodb
    - ME_CONFIG_MONGODB_ADMINUSERNAME=root
    - ME_CONFIG_MONGODB_ADMINPASSWORD=password
    - ME_CONFIG_BASICAUTH_USERNAME=admin
      - ME_CONFIG_BASICAUTH_PASSWORD=password
  ports:
    - "8081:8081"

Tag summary

Content type

Image

Digest

sha256:f957bdea5…

Size

221.8 MB

Last updated

about 2 years ago

docker pull toniin/api-contact-manager