diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8396370..b5a28cd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -16,6 +16,13 @@ jobs: runs-on: ${{ matrix.os }} + env: + HOST: localhost + PORT: 5432 + USER: root + PASSWORD: root + DBNAME: root + steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..084c7fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:latest + +EXPOSE 8000 + +WORKDIR /app + +ENV HOST=localhost PORT=5432 +ENV USER=root PASSWORD=root DBNAME=root + +COPY ./main.exe . + +CMD [ "./main.exe" ] \ No newline at end of file diff --git a/database/db.go b/database/db.go index 01b3d50..bb765c2 100644 --- a/database/db.go +++ b/database/db.go @@ -2,7 +2,7 @@ package database import ( "log" - + "os" "github.com/guilhermeonrails/api-go-gin/models" "gorm.io/driver/postgres" "gorm.io/gorm" @@ -14,7 +14,7 @@ var ( ) func ConectaComBancoDeDados() { - stringDeConexao := "host=localhost user=root password=root dbname=root port=5432 sslmode=disable" + stringDeConexao := "host=" + os.Getenv("HOST") + " user=" + os.Getenv("USER") + " password=" + os.Getenv("PASSWORD") + " dbname=" + os.Getenv("DBNAME") + " port=" + os.Getenv("PORT") + " sslmode=disable" DB, err = gorm.Open(postgres.Open(stringDeConexao)) if err != nil { log.Panic("Erro ao conectar com banco de dados") diff --git a/main.exe b/main.exe new file mode 100644 index 0000000..6b9d0bc Binary files /dev/null and b/main.exe differ