claudinhoandrade/gameshop

By claudinhoandrade

Updated 7 months ago

JAVA REST API SPRING BOOT APPLICATION

Image
API Management
Databases & Storage
Languages & Frameworks

5

Inspecting the image:

docker run -d -p 8080:8080 claudinhoandrade/gameshop:latest

Go to the web-browser and type: http://127.0.0.1:8080/swagger-ui/index.html (Changing the IP according to the Machine location, if it's necessary.)

Status of the container:

docker container ps

Stop : docker container stop CONTAINER_ID

Although the container runs well, would be better persist the data with some database. The docker-compose written below is exactly what you need to do it without trouble.

########################################################

Docker Compose

########################################################

version: '2'

    services:

       app:

          image: 'claudinhoandrade/gameshop:latest'

          build:

              context: .

           container_name: app

           depends_on:

                - db

           ports:

                 - "8080:8080"

           environment:

              - POSTGRES_USER=compose-postgres

              - POSTGRES_PASSWORD=compose-postgres

              - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/compose-postgres

              - SPRING_DATASOURCE_USERNAME=compose-postgres

              - SPRING_DATASOURCE_PASSWORD=compose-postgres

              - SPRING_JPA_HIBERNATE_DDL_AUTO=update


       db:

           image: 'postgres:13.1-alpine'

           container_name: db

           ports:

                - "5434:5432"

           volumes:

                 - /postgres-data:/var/lib/postgresql/data

           environment:

                 - POSTGRES_USER=compose-postgres

                 - POSTGRES_PASSWORD=compose-postgres

           restart: always

########################################################

Please, make sure that the file is in the correct indentation (YAML file), otherwise will not work.

Code available at:

https://github.com/claudio-es-andrade/gameShopDTO

Docker Pull Command

docker pull claudinhoandrade/gameshop