dmioto / problem-company-challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem Company Challenge

A server that handles requests and performs operations with a Postgres database, using Docker to setup.

Customer Model

  • First Name
  • Last Name
  • Email
  • Password (hash)

Running...

Using Ubuntu 18.04

Runing the following command, docker will automatically initiate, define the API port, environment variables, build and run Postgres backend container.

sudo start.sh

Using other Operational Systems

Create a Docker Network to make the connection between Postgres and backend. We'll consider the name of this network to be "problem-network".

sudo docker network create problem-network

Start the Postgres container and connect it to the problem-network.

sudo docker run -d -e POSTGRES_PASSWORD=postgres --name=problem-database --network=problem-network postgres:14.5-alpine

Run the application using the following commands:

Create a docker network to make the communication between the two containers (database and backend), which then will run in the same host.

sudo docker network create problem-network

Run the database. We'll consider the name of this database to be "problem-database".

sudo docker run -e POSTGRES_PASSWORD=postgres --name=problem-database --network=problem-network postgres:14.5-alpine

Get the IP of the database container inside of the problem-network.

IP=sudo docker network inspect problem-network | grep -o -P "(?<=\"IPv4Address\": \").*(?=/)"
echo $IP

Run the backend.

sudo docker run --network=problem-network teste

About


Languages

Language:Go 81.6%Language:Shell 16.5%Language:Dockerfile 1.9%