Skip to content

Blog API demo to test case FastAPI and Docker functionalities

Notifications You must be signed in to change notification settings

rodrigofrancisco/blogg-API

Repository files navigation

Simple blog app

Simple blog app utility to test FastAPI library and Docker functionalities

Docker testing

  • Building blog-app image
    docker build -t blogg .
        
  • Running blog app
    docker run -p 8000:8000 --network host blogg
        
  • Launching Postgres database
    docker run --name postgres-blog -e POSTGRES_PASSWORD="" \
        -p 5432:5432 --network host -d postgres
        
  • Creating database blog
    docker exec -it postgres-blog /bin/bash
    # On the container:
    psql -h localhost -p 5432 -U postgres -W
    # On pgsql shell
    create database blog;
    \q
    exit
        

Docker compose

docker-compose -f docker-compose.yaml up --build

Current Steps

As I’m perfecting this, the steps are quite annoying

  1. User docker-compose
    docker-compose -f docker-compose.yaml up --build
        
  2. Above step will fail the first time. Manually enter the postgres-blog container to create the database
    docker exec -it postgres-blog /bin/bash
    # On the container:
    psql -h localhost -p 5432 -U postgres -W
    # On pgsql shell
    create database blog;
    \q
    exit
        
  3. Run docker compose again. It should be ready

About

Blog API demo to test case FastAPI and Docker functionalities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published