Skip to content

Commit

Permalink
Merge pull request #7 from AdautoDCJunior/lesson-02-ci-pipeline-docke…
Browse files Browse the repository at this point in the history
…r-git-actions

Aula 02 do curso "Integração Contínua: Pipeline Docker no Github Actions"
  • Loading branch information
AdautoDCJunior authored Jan 19, 2024
2 parents 60587cb + 5d2b736 commit 452a848
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
4 changes: 2 additions & 2 deletions database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package database

import (
"log"

"os"
"github.com/guilhermeonrails/api-go-gin/models"
"gorm.io/driver/postgres"
"gorm.io/gorm"
Expand All @@ -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")
Expand Down
Binary file added main.exe
Binary file not shown.

0 comments on commit 452a848

Please sign in to comment.